I royally screwed up with version control and deleted a bunch of files including migrations. I tried then to rails generate the files with the same names but then got (error, record already exists). I realized the table must already exist in the database.
If I run rake db:migrate:status
I get the following:
up 20150426172505 Remove columns from businesses categories sub categories
up 20150426172902 Change pdf name
up 20150520193556 ********** NO FILE **********
up 20150520194841 ********** NO FILE **********
up 20150527194215 ********** NO FILE **********
How do I get rid of the missing migrations and get the schema to use 20150426172902?
Well, there are two ways you can get rid of those lost migration files.
One is to run the following command:
This will completely drop down your database, re-run all the migration, and run the seeds if you have any.
Second is to run the following query, and directly deleting the lost migration files that you do not want to see around.