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

Comments

Projects
None yet
2 participants
@mattbrictson
Member

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

This comment has been minimized.

Show comment
Hide comment
@will-in-wi

will-in-wi Oct 1, 2017

Contributor

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?

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@mattbrictson

mattbrictson Oct 1, 2017

Member

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

Member

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

This comment has been minimized.

Show comment
Hide comment
@will-in-wi

will-in-wi Oct 1, 2017

Contributor

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.

Contributor

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

This comment has been minimized.

Show comment
Hide comment
@will-in-wi

will-in-wi Oct 12, 2017

Contributor

The cookbook has been merged. Closing this feature request.

Contributor

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