Skip to content
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

Feature request: allow me to turn off automatic database migrations #199

Closed
mattbrictson opened this issue Mar 2, 2017 · 4 comments
Closed
Labels

Comments

@mattbrictson
Copy link
Member

@mattbrictson mattbrictson commented Mar 2, 2017

This has been discussed in #167, but that PR has since been abandoned. I am moving the discussion here.

Right now capistrano-rails attempts to run database migrations on every deploy. This is undesirable for some applications according to the following comments (see below, copied and pasted from #167).

Ideally capistrano-rails would provide both of these things:

  • A way to turn auto-migrations off; and
  • A task to trigger a migration manually

Sometimes you may need to run migrations after the actual deploy. For example, if a migration locks the DB, etc. A common case is adding an index to your DB, the functionality is the same, but the addition can cause locks. In this case you may need to run the migration later, but still need to deploy the code.

Our workflow is this: simple migrations (on small tables) can be done using rake db:migrate, but larger ones need to be run manually using third-party tools like, in our case for MySQL, https://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html. If accidentally someone in our team runs such a larger migration, it could cause a lot of trouble for us (we recently had 30 minutes downtime because of a larger ALTER TABLE on our MySQL Galera cluster).

@will-in-wi
Copy link
Contributor

@will-in-wi will-in-wi commented Oct 1, 2017

This might be somewhat fixable by adding:

if ENV['RUN_MIGRATIONS'].present?
  require 'capistrano/rails/migrations'
end

to the Capfile, and then by running:

RUN_MIGRATIONS=true bundle exec cap production deploy:migrate

Is this a sane solution to this issue?

@mattbrictson
Copy link
Member Author

@mattbrictson mattbrictson commented Oct 1, 2017

That seems like a good solution to me. Would you be willing to open a PR to add that to the README?

@will-in-wi
Copy link
Contributor

@will-in-wi will-in-wi commented Oct 1, 2017

I'm beginning to wonder whether it would make sense to create some sort of "cookbook" page on the website with all of these solution types of things. I've closed a couple of tickets because someone found a decent workaround which we could document there. I'm not sure I want to add everything to the readme.

@will-in-wi
Copy link
Contributor

@will-in-wi will-in-wi commented Oct 12, 2017

The cookbook has been merged. Closing this feature request.

@will-in-wi will-in-wi closed this Oct 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.