Wednesday, 15 January 2014

ruby on rails - How do I fix my database when I've deleted the current migration file? -


My problem is that I was doing some spiking at some point and I migrated my database with that migration in which I had made Spike branch again I came back to my master branch (I have never traveled). Now this migration is always in my database and it is making it impossible to migrate my database.

When I run

ActiveRecord :: Migrator.get_all_versions

My deleted migration file timestamp in this array is in this array I want to remove this version from the migrator. Also I can not leave the database

If the database can be blown off, then the fastest way would be to leave the database, , And re-apply the migration with the following steps:

  rake db: drop rake db: create db: migrate  

if in the database Useful Information & amp; If it can not be blown away, then it is difficult. Only the potential option will go to the database level, and the changes made by the migration have to be reversed.

Which tables / columns were added / deleted in the migration, and then run SQL scripts to reverse those changes.

In addition to this, delete a specific line related to this migration: With the following query: Delete the schema_migrations table, with the following query:

  schema_migrase where version = ' 201503 ...... ' 

No comments:

Post a Comment