开发者

Should a rails migration be committed separately from schema.rb?

After generating / writing / running a Rail开发者_高级运维s database migration, should the migration file and db/schema.rb be committed to version control separately?


Some rake tasks that should be similar may behave differently if schema.rb is not in sync with migrations, for example:

After creating the database, if you run:

rake db:migrate - it'll run the migrations

rake db:schema:load - it'll use the schema.rb

Reseting the database:

rake db:migrate:reset - recreates the database running the migrations one by one.

rake db:reset - recreates the database using current version of schema.rb

In both cases, no matter which task you choose, the result should be the same. Normally, using schema.rb is preferred since it creates the database in one step, instead of passing for every single migration, but if it's not the same version as the migrations the results will be different.


Most people I've seen commit them in a single commit.

It makes more sense to me that way. It makes sure that running a rake db:migrate on any revision doesn't modify db/schema.rb.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜