Should I flatten Rails migrations?

浪子不回头ぞ 提交于 2019-12-30 08:16:47

问题


It's possible to replace db/migrate/* with the contents of db/schema.rb, so that you only have one migration step.

Do any of you ever do this? Why?


回答1:


Why would you want to do this? You could just run rake db:schema:load if you don't want to run all migrations. Migrations are used not (only) to initialize a new database, but to migrate it to another version.




回答2:


Also, some big Ruby on Rails kit packages (like that one that's slipping my mind now that lets you set up an ecommerce site in your Rails app), flatten their migrations.

I've also known of projects with a ton of migrations to do this every once in a while to reduce the amount of time it takes to run rake db:migrate start to finish (say, on the continuous integration server)




回答3:


You can do rake db:schema:load to import the entire schema in one step. This is recommended, as opposed to running a ton of migrations.



来源:https://stackoverflow.com/questions/1910001/should-i-flatten-rails-migrations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!