I deleted the migration file after executing $ rails db: migrate, and a NO FILE file was created.
Terminal
rails db:migrate:status
Then it will be displayed like this ↓
Terminal
 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20200602094458  Create messages
   up     20200604080747  ********** NO FILE **********
Terminal
touch db/migrate/20200604080747_hoge.rb
20200604080747_hoge.rb
class Hoge < ActiveRecord::Migration[5.2]
  def change
  end
end
Terminal
rails db:migrate:status
Then it will be displayed like this ↓
Terminal
 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20200602094458  Create messages
   up     20200604080747  Hoge
Terminal
rails db:migrate:down VERSION=20200604080747
Check if it is down
Terminal
rails db:migrate:status
↓
Terminal
 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20200602094458  Create messages
  down    20200604080747  Hoge
 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20200602094458  Create messages
Be careful when handling migration files. It's a considerable loss of time.
Recommended Posts