Question summary:
I cloned an open source project called DMP Roadmap and follow its installation guide until rake db:schema:load
.
Then I do rake db:migrate
which produce no output in terminal, but I notice the schema.rb file got modified. I don't think this should happen because rake db:migrate
doesn't produce any output, which should imply that nothing will be changed, but the schema file is changed.
There must be something going on underneath, can anyone who knows the ins and outs of DB migration please explain what happened underneath?
Step to reproduce:
On Mac OS, brew install mariadb (brew info mariadb
will say: stable 10.3.9 (bottled))
Follow the installation guide:
git clone https://github.com/DMPRoadmap/roadmap.git
cd roadmap
cp config/database_example.yml config/database.yml
cp config/secrets_example.yml config/secrets.yml
cp config/branding_example.yml config/branding.yml
cp config/initializers/devise.rb.example config/initializers/devise.rb
cp config/initializers/recaptcha.rb.example config/initializers/recaptcha.rb
cp config/initializers/wicked_pdf.rb.example config/initializers/wicked_pdf.rb
bundle install
rake secret
vi config/secrets.yml # put the secret generated above into `config/secret.yml`
rake db:create
rake db:schema:load
rake db:migrate
Part of the git diff after doing rake db:migrate
:
ActiveRecord::Schema.define(version: 20180508151824) do
create_table "annotations", force: :cascade do |t|
- t.integer "question_id"
- t.integer "org_id"
- t.text "text"
- t.integer "type", default: 0, null: false
+ t.integer "question_id", limit: 4
+ t.integer "org_id", limit: 4
+ t.text "text", limit: 65535
+ t.integer "type", limit: 4, default: 0, null: false
t.datetime "created_at"
t.datetime "updated_at"
end
- add_index "annotations", ["question_id"], name: "index_annotations_on_question_id"
+ add_index "annotations", ["org_id"], name: "fk_rails_aca7521f72", using: :btree
+ add_index "annotations", ["question_id"], name: "index_annotations_on_question_id", using: :btree
create_table "answers", force: :cascade do |t|
- t.text "text"
- t.integer "plan_id"
- t.integer "user_id"
- t.integer "question_id"
+ t.text "text", limit: 65535
+ t.integer "plan_id", limit: 4
+ t.integer "user_id", limit: 4
+ t.integer "question_id", limit: 4
t.datetime "created_at"
t.datetime "updated_at"
- t.integer "lock_version", default: 0
+ t.integer "lock_version", limit: 4, default: 0
end
- add_index "answers", ["plan_id"], name: "index_answers_on_plan_id"
- add_index "answers", ["question_id"], name: "index_answers_on_question_id"
+ add_index "answers", ["plan_id"], name: "index_answers_on_plan_id", using: :btree
+ add_index "answers", ["question_id"], name: "index_answers_on_question_id", using: :btree
+ add_index "answers", ["user_id"], name: "fk_rails_584be190c2", using: :btree
create_table "answers_question_options", id: false, force: :cascade do |t|
- t.integer "answer_id", null: false
Extra questions:
- Why did it add a bunch of limit and btree?
- Why did it add this line:
+ add_index "annotations", ["org_id"], name: "fk_rails_aca7521f72", using: :btree
? It wasn't here before