-
Notifications
You must be signed in to change notification settings - Fork 270
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
db:rollback #110
Comments
The best practice is usually to keep db schema/migrations capable with previous version of app. By using this trick, you will make the old-running code capable with the new schema (at the moment when DB is already migrated but app is not restarted yet). But generally speaking, we could add this task as a optional and mention it in README. |
@kirs this is good approach. Though |
Add lib/capistrano/tasks/db_rollback.rake namespace :deploy do
namespace :db do
desc 'Rollback db'
task rake: [:set_rails_env] do
on release_roles([:db]) do
within release_path do
with rails_env: fetch(:rails_env) do
execute :rake, "db:rollback
end
end
end
end
end
end That file will we autoloaded bu Capfile # Load custom tasks from `lib/capistrano/tasks` if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } |
I agree with @printercu, during development/testing you may write incorrect migration, run it (within cap deploy), get error, re-write migration to make it correct, rollback (it'd be nice to do it within cap task), git push, cap deploy:migrate. It's especially useful for non-translational DDL dbs, like MySQL. |
This could get hairy when there are multiple migrations in a single release: http://edgeguides.rubyonrails.org/active_record_migrations.html#rolling-back It is also possible that only a few migration succeeded. Unsure what migration Just a few things to take into consideration here. |
The latest successful.
|
Hi, I wanted to rollback an application but the database was not rolled back.
What do you think about adding a
deploy:db:rollback
to this gem. This task could be also hooked after thedeploy:reverted
hook and runrake db:rollback
The text was updated successfully, but these errors were encountered: