简体   繁体   English

schema.rb中的随机变化

[英]random changes in schema.rb

I've noticed this for months and I just didn't have the time to deal with it until now. 我已经注意到了几个月,而直到现在我都没有时间去处理它。 Whenever my CI server does an automatic git pull and restarts the rails servers, the schema.rb gets randomly modified. 每当我的CI服务器执行自动git pull并重新启动rails服务器时,都会随机修改schema.rb As the example shows below, the api_name column of a certain table got dropped. 如下例所示,某个表的api_name列被删除。 I dropped this column about 3 months ago. 我在3个月前删除了此专栏。 Same with transportation_charges . transportation_charges相同。 And very often, the spacing in this file changes: see created_at and updated_at . 通常,此文件中的间距会更改:请参见created_atupdated_at

It's especially annoying since on the next run, when my CI does an initial git pull , it complains about changes to schema.rb and stops execution until they get pushed or reverted. 自从下一次运行时,当我的CI进行初始git pull ,它特别烦人,它抱怨对schema.rb更改并停止执行,直到被推送或还原为止。 And it's not just the CI server. 不仅是CI服务器。 I've seen this on other developer machines as well. 我在其他开发人员机器上也看到了这一点。 Did anyone run into this before? 有人遇到过吗?

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

When you run a migration, the schema gets updated not just by the migration, but also the current database. 运行迁移时,不仅会通过迁移来更新架构,还会更新当前数据库。 I'm guessing some of your developers are using databases inconsistent with the schema. 我猜您的一些开发人员正在使用与架构不一致的数据库。 Then you'll get unexpected changes every time they run a migration. 这样,每当他们运行迁移时,您都将获得意外的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM