How to run a specific migration in rails?
In order to run a specific migration we need to specify the VERSION
of the migration.
For example:
# RAILS >= 5.0
rails db:migrate:up VERSION=20230906123456
# RAILS < 5.0
rake db:migrate:up VERSION=20230906123456
If you want to rollback a specific migration
# 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.