如何修改capistrano部署以自动运行Rails 3.0中的迁移

时间:2021-09-22 00:15:09

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

现在,我必须运行cap部署和cap部署:如果要运行迁移,那么就进行迁移。

how I modify the cap deploy task to run migrations.

如何修改cap部署任务以运行迁移。

2 个解决方案

#1


44  

Just add:

添加:

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

to your config/deploy.rb.

你的配置/ deploy.rb。

#2


10  

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

运行“cap部署:迁移”等同于在一个命令中运行“cap部署”和随后的“cap部署:迁移”。

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

要查看部署描述:迁移,只需使用-e选项:

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.

部署和运行等待迁移。这与“部署”任务类似,但也会在更新符号链接之前运行任何未决迁移(通过“部署:迁移”任务)。注意,本例中的更新不是原子性的,事务也没有使用,因为迁移不能保证是可逆的。

#1


44  

Just add:

添加:

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

to your config/deploy.rb.

你的配置/ deploy.rb。

#2


10  

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

运行“cap部署:迁移”等同于在一个命令中运行“cap部署”和随后的“cap部署:迁移”。

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

要查看部署描述:迁移,只需使用-e选项:

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.

部署和运行等待迁移。这与“部署”任务类似,但也会在更新符号链接之前运行任何未决迁移(通过“部署:迁移”任务)。注意,本例中的更新不是原子性的,事务也没有使用,因为迁移不能保证是可逆的。