Akhil Yadav Akhil Yadav - 5 months ago 18
MySQL Question

restore deleted column from mysql db on different git branch

In my test branch, I ran a rails migration to remove a column from one of my database tables. The migration ran successfully and the column was deleted.
But then I created another fresh branch from master in which I needed that column and checked-out onto it.
The column was still deleted, but my model had the attribute, and also there is no migration in this branch that I can rollback to get the column back.

Answer

You have to reset the db migrations. Run this command in cmd to reset the migrations:

rake db:migrate:reset

It'll reset your database depends on your current branch's migration. If you move to your previous branch where you delete your column you've to run the command again to apply the changes.

Comments