How to db:migrate after db:schema:load
I have a production db, that I prepare w开发者_StackOverflowith
rake db:create db:schema:load db:seed
I also include migrations, when delivering my product, so that existing installations can be updated.
After schema:load only the version of the latest migration is stored in schema_migrations, so when I run db:migrate, the migrator tries to run all other migrations that are not yet in schema_migrations.
Is there a good way, to deal with this, that does not require me, to collapse migrations (because that is unfortunately out of the question - just like db:migrate as the preparation step)?
Just don't db:schema:load, pass migrations instead:
rake db:create db:migrate db:seed
Please keep in mind that in big/long projects passing migrations is a hard way. You should tru to keep your seeds.rb updated and use you way. Old migrations tends to fail because of incompatible model changes (in respect to old migrations) as the project evolutes.
精彩评论