-
Notifications
You must be signed in to change notification settings - Fork 269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reenable for migrations on multiple servers #189
Comments
I believe that this was fixed in #168 which came out in 1.1.7. |
As you can see from the log output I'm getting this error on |
The error is correct. It looks like you are trying to reinvoke the task on multiple servers. You should use the feature in #168 which allows you to use |
That's correct, I need migrations to be invoked on multiple servers and I have following configuration to do that: server '...', user: '...', roles: %w(app db web)
server '...', user: '...', roles: %w(app db web)
set :migration_servers, -> { release_roles(fetch(:migration_role)) } So it tries to run migration on both servers but the second one was skipped due to this error. |
Just to clarify: 3.6.0 did not change any behavior. Prior to 3.6.0 multiple invocations would simply fail silently. Starting with 3.6.0 they fail and a warning is printed. That said, this does seem to be a legitimate bug in capistrano-rails. The current implementation looks like this (pseudo code):
The code for multiple servers uses two nested I believe some extensive changes are needed to make multi-migrations work. Does anyone want to give it a try? |
Is there a reason while the migration task is splitted into two separate tasks? namespace :deploy do
desc 'Runs rake db:migrate if migrations are set'
task :migrate => [:set_rails_env] do
on fetch(:migration_servers) do
conditionally_migrate = fetch(:conditionally_migrate)
info '[deploy:migrate] Checking changes in db' if conditionally_migrate
if conditionally_migrate && test("diff -qr #{release_path}/db #{current_path}/db")
info '[deploy:migrate] Skip `deploy:migrate` (nothing changed in db)'
else
info '[deploy:migrate] Run `rake db:migrate`'
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, 'db:migrate'
end
end
end
end
end
after 'deploy:updated', 'deploy:migrate'
end |
Merge both migration tasks into one, to avoid unnecessary invocations
I can think of a couple reasons:
But first, let's back up: are we certain that the migrations are not being run on multiple servers? When I re-read the code, I realized that even though @disem Can you please verify again whether migrations are actually being run (e.g. by looking at the full Capistrano log output), despite the warning that's printed? |
@mattbrictson will check tomorrow. |
@mattbrictson you are right! I've missed these two points. I've stumbled over the same warning message last week and thought the migration is not executed on all servers. But as you've assumed after looking precise in the logs, the migrations is executed on all servers: So this is not a bug, but an unsightly warning. We could avoid this warning with: invoke :'deploy:migrating' unless Rake::Task[:'deploy:migrating'].already_invoked What you think about this? |
@Landreas Yes, |
@mattbrictson i've updated #191. 🙂 |
Fix migrations on multiple servers (#189)
Since capistrano 3.6.0 multiple database servers don't work because of:
The text was updated successfully, but these errors were encountered: