Meltemi
Meltemi

Reputation: 38349

Rails: db:migrate inconsistently alters schema.rb on my box

Pulled down some updates from Github and ran the migrations rails db:migrate and noticed Git tracking changes to the repo. A shortened diff of schema.rb shows it inserting id: :serial, everywhere?

Anyone know what's going on? Safe to dump this? It's not present on other developer's machines? Is this a setting I'm not aware of?

-  create_table "boxes", force: :cascade do |t|
+  create_table "boxes", id: :serial, force: :cascade do |t|
     t.text "name", default: "", null: false
     t.datetime "created_at", null: false
     t.datetime "updated_at", null: false
@@ -107,7 +107,7 @@ ActiveRecord::Schema.define(version: 2019_05_27_143936) do
     t.index ["user_id"], name: "index_boxes_on_user_id"
   end

-  create_table "comments", force: :cascade do |t|
+  create_table "comments", id: :serial, force: :cascade do |t|
     t.text "body", null: false
     t.integer "commentable_id", null: false
     t.string "commentable_type", null: false
@@ -116,7 +116,7 @@ ActiveRecord::Schema.define(version: 2019_05_27_143936) do
     t.datetime "updated_at", null: false
   end

Upvotes: 1

Views: 470

Answers (1)

siegy22
siegy22

Reputation: 4413

Changes in the generated schema.rb or structure.sql are often caused when you update your postgres server or you update rails.

To this specific problem, it seems there's already an answer: What determines if rails includes id: :serial in a table definition?

Upvotes: 1

Related Questions