Open webdevilopers opened 8 years ago
Make sure that the Gemfile looks like this:
gem 'capistrano', '~> 3.1.0'
gem 'capistrano-symfony'
gem 'capistrano-symfony-doctrine'
And the Capfile looks like this:
require 'capistrano/symfony'
require 'capistrano/symfony-doctrine'
You also have to make sure that the task is executed after the deploy is made. The deploy.rb should look like this:
after 'deploy:updated', 'symfony:doctrine:migrations'
I've used this for quite some time now and it works great, I'm also using Capistrano 3.4.0.
The task will run on each deploy but will only run new migrations added in the latest deploy. You have to use the --no-interaction
flag in order for the migrations to execute automatically without getting into interaction mode during the deploy.
Sorry for the late reply but I think I've found your problem.
The server that you want to execute this script on must have the role db. The reason for this is because you might be having multiple web nodes but you only want to execute this on one of the nodes to avoid errors!
server 'node1.example.com', user: 'root', roles: %w{web db}
server 'node2.example.com', user: 'root', roles: %w{web}
server 'node3.example.com', user: 'root', roles: %w{web}
I'll make sure to add this to the readme
I tried the following settings:
server 'stage.example.com', roles: %w{web db}, user: "example"
namespace :deploy do
after 'deploy:updated', 'symfony:doctrine:migrations'
end
Cap aborts:
cap aborted! SSHKit::Runner::ExecuteError: Exception while executing as example@example.com: cd '/var/www/vhosts/.../htdocs/releases/20160826130140'; app/console doctrine:migrations:migrate --no-interaction --no-debug exit status: 126 cd '/var/www/vhosts/.../htdocs/releases/20160826130140'; app/console doctrine:migrations:migrate --no-interaction --no-debug stdout: Nothing written cd '/var/www/vhosts/.../htdocs/releases/20160826130140'; app/console doctrine:migrations:migrate --no-interaction --no-debug stderr: bash: app/console: Keine Berechtigung /var/lib/gems/1.9.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:16:in
rescue in block (2 levels) in execute' /var/lib/gems/1.9.1/gems/sshkit-1.7.1/lib/sshkit/runners/parallel.rb:12:in
block (2 levels) in execute' SSHKit::Command::Failed: cd '/var/www/vhosts/.../htdocs/releases/20160826130140'; app/console doctrine:migrations:migrate --no-interaction --no-debug exit status: 126
Make sure that you are using the latest version of doctrine migrations & the doctrine migration bundle. I know there have been issues regarding that in earlier versions
Capistrano Version: 3.4.0 (Rake Version: 10.4.2)
Capfile:
My former integration for migrations:
Now I use:
Not sure if the namespace loop is required and I can simply use:
Anyways the migrations are no running. Currently all versions were migrated. Will the task then be skippend? Using my original code I at least got the interaction mode and was asked for migrating - even if no migration versions were to be migrated.