我已经注意到了这个月,直到现在我还没有时间处理它。每当我的CI服务器自动执行git pull
并重新启动导轨服务器时,schema.rb
将被随机修改。如下例所示,某个表的api_name
列被删除。大约三个月前我放弃了这个专栏。与transportation_charges
相同。很多时候,此文件中的间距会发生变化:请参阅created_at
和updated_at
。schema.rb中的随机变化
特别讨厌,因为在下一次运行时,当我的CI初始化为git pull
时,它抱怨对schema.rb
的更改并停止执行,直到它们被推或恢复。它不只是CI服务器。我也在其他开发者机器上看到了这一点。有没有人遇到过这个?
diff --git a/db/schema.rb b/db/schema.rb
index 470d3bf..166e3ee 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -883,7 +883,6 @@ ActiveRecord::Schema.define(version: 20170720211740) do
create_table "ups_package_service_options", force: :cascade do |t|
t.string "name"
- t.string "api_name"
t.string "type"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
@@ -910,9 +909,8 @@ ActiveRecord::Schema.define(version: 20170720211740) do
t.string "code"
t.string "name"
t.string "api_name"
- t.decimal "transportation_charges"
- t.datetime "created_at", null: false
- t.datetime "updated_at", null: false
+ t.datetime "created_at", null: false
+ t.datetime "updated_at", null: false
t.boolean "domestic"
end
珍娜,是'.gitignore'文件中的'schema.rb'? – MatayoshiMariano
不是应该忽略吗?我读过这是一个好主意,让它在版本控制下。特别是,因为我总是有新的服务器,所以我需要将它部署在下面,所以这对于执行rake db:setup很有用。我确实有数百次迁移。 –
Jenna我一直忽略'schema.rb',因为它避免了这种冲突,更重要的是,如果我从scracth运行'rake db:migrate',我可以保证所有的迁移工作。然而,我一直在寻找一些关于忽略或不关注的信息:[Link1](https://stackoverflow.com/questions/6450263/what-is-the-right-approach-to-deal-with-rails-db-schema- rb-file-in-git),[Link2](https://stackoverflow.com/questions/737854/what-is-the-preferred-way-to-manage-schema-rb-in-git),[Link3 ](http://thelazylog.com/you-should-always-commit-gemfile-lock-and-schema-rb/) – MatayoshiMariano