How to modify capistrano deploy to automatically run migrations in Rails 3.0

后端 未结 2 759
执念已碎
执念已碎 2020-12-30 23:26

Right now, I have to run cap deploy and cap deploy:migrations if there are migrations to be run.

how I modify the cap deploy task to run migrations.

相关标签:
2条回答
  • 2020-12-30 23:49

    Running "cap deploy:migrations" is equivalent to running "cap deploy" && subsequently "cap deploy:migrate" in one command.

    To view the description for deploy:migrations, just use the -e option:

    cap -e deploy:migrations
    

    will give you this output:

    cap deploy:migrations
    

    Deploy and run pending migrations. This will work similarly to the 'deploy' task, but will also run any pending migrations (via the 'deploy:migrate' task) prior to updating the symlink. Note that the update in this case it is not atomic, and transactions are not used, because migrations are not guaranteed to be reversible.

    0 讨论(0)
  • 2020-12-30 23:50

    Just add:

    after "deploy:update_code", "deploy:migrate"
    

    to your config/deploy.rb.

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