In production and team environments rerunning prior Rails database migrations is generally not recommended. However there are times when it can be useful, for example when revising a feature branch that has yet to be committed, based on a change to the data model.

In this case, the previous migration may be run again using the form rails db:migrate:redo VERSION=xxxxxxx, for example:

$ rails db:migrate:redo VERSION=20200718231958
== 20200718231958 CreateProducts: reverting ====================================
-- drop_table(:products)
   -> 0.0360s
== 20200718231958 CreateProducts: reverted (0.0473s) ===========================

== 20200718231958 CreateProducts: migrating ====================================
-- create_table(:products)
   -> 0.0294s
== 20200718231958 CreateProducts: migrated (0.0295s) ===========================

db:migrate:redo can also be used with a STEP parameter:

$ rails db:migrate:redo STEP=2

This reverts the previous 2 migrations, and runs them again.