如何在 db:schema:load 之后进行 db:migrate
我有一个生产数据库,
rake db:create db:schema:load db:seed
在交付产品时我还准备了一个生产数据库,以便可以更新现有安装。
在 schema:load 之后,仅最新迁移的版本存储在 schema_migrations 中,因此当我运行 db:migrate 时,迁移器会尝试运行 schema_migrations 中尚未存在的所有其他迁移。
有没有一个好的方法来处理这个问题,不需要我折叠迁移(因为不幸的是这是不可能的 - 就像 db:migrate 作为准备步骤一样)?
I have a production db, that I prepare with
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是不要 db:schema:load,而是传递迁移:
请记住,在大/长项目中传递迁移是一种困难的方法。您应该真正保持您的 seeds.rb 更新并按您的方式使用。随着项目的发展,由于不兼容的模型更改(相对于旧迁移),旧迁移往往会失败。
Just don't db:schema:load, pass migrations instead:
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.