我已經注意到了這個月,直到現在我還沒有時間處理它。每當我的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