Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a capistrano rollback undo migrations?

I'm new to this. I have a production server and need to deploy the latest version of the application from github, so I'm using Capistrano.

The newest release makes some changes to the database and hence has a bunch of migrations, so I'll be deploying it with deploy:migrate.

So my question was, if I add some data to the new columns created (it doesn't change any of the existing columns in the tables, just creates new tables and columns) and then want to rollback, then will cap deploy:rollback reverse all the migrations as well? Is the data in those new columns erased and the database back to the previous state (assuming I didn't make any data change except to the new additions in the db)?

Thanks!

like image 487
Achint Avatar asked Oct 21 '14 16:10

Achint


People also ask

What does a migration rollback do?

Rollback All Migrations: rollback all means it will reset all migration. so if you change anything on migration file then it will recreate and affect it.

How do you undo migrations in rails?

To check for status, run rails db:migrate:status . Then you'll have a good view of the migrations you want to remove. Then, run rails db:rollback to revert the changes one by one. After doing so, you can check the status again to be fully confident.

Which command is true to rollback migration in Rails?

You must rollback the migration (for example with bin/rails db:rollback ), edit your migration, and then run bin/rails db:migrate to run the corrected version.


1 Answers

No, it will not. You would need to manually run the down part of those migrations via rake and then roll back.

However, if your current app won't be affected by the new rows it won't hurt anything.

like image 138
Philip Hallstrom Avatar answered Sep 28 '22 10:09

Philip Hallstrom