Rolling back Rails Database migrations

Photo by Jim Wilson on Unsplash

Rolling back Rails Database migrations


1 min read

I ran into a situation at work where I had to roll back Rails migrations to get my database back into a usable state.

rails db:migrate:status - This shows us the current status of our migrations.

StatusMigration IDMigration
up20350319081542First migration
up20350419081542Second migration
up203504519081542Third migration

rails db:rollback - This lets you roll back one migration at a time.

rails db:migrate:down VERSION=20350419081542 - This rolls back this specific migration file.