How to rollback a specific migration in rails?

less than 1 minute read

In order to rollback a specific migration we need to specify the VERSION of the migration.

For example:

# RAILS >= 5.0
rails db:migrate:down VERSION=20230906123456

# RAILS < 5.0
rake db:migrate:down VERSION=20230906123456

NOTE:

If a version is not found rails will throw an exception

rails db:migrate:down VERSION=20000906123456

bin/rails aborted!
ActiveRecord::UnknownMigrationVersionError:

No migration with version number 20000906123456.

References