Akhil Yadav Akhil Yadav - 1 year ago 95
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download