Way to “flatten” Rails migrations?

前端 未结 2 1203
半阙折子戏
半阙折子戏 2021-02-13 22:26

I\'m working on deploying my first Rails application right now, and somewhere along the way, I botched a migration. When I try to push my application to the production server an

相关标签:
2条回答
  • 2021-02-13 22:38

    If you edited the schema directly you will need to run:

    rake db:schema:dump
    

    This will take whatever is in the database and create a schema.rb file. Then you can run rake db:schema:load anytime you want. However it will mean that your migrations are still bad. You could delete all of them and recreate them from the schema.rb file.

    0 讨论(0)
  • 2021-02-13 22:57

    This is what the db/schema.rb file is for. If you've only got structural changes in your migrations you will be able to run rake db:schema:load rather than running rake db:migrate to get the absolute structure for your tables.

    0 讨论(0)
提交回复
热议问题