How to solve migration issues with rails
Greetings friends!!! Migrations make managing your database schema easy, however, problems often occur when we're running our migrations and run into a bug in our migration code. It can leave your migrations in a broken state where you can't migrate up and you can't migrate down. It's important to learn how this happens and how to resolve these problems when they occur. Use rails db:migrate version 0 to migrate to 0 level. STEPS to recover migrations issue: Make a note of migration issue. Try to resolve it manually by changing migration file. Perform migration to version 0. This will rollback all migrations. Comment all above code inside migration having an issue. Let's say for example if your line # 5 is causing an issue comment your code till line #4. Run rails db:migrate again Verify that it shows success and double check with the database too, If it showing migration error perform step 1 to 5 till it shows the success. Uncomment your code and yo...