About this article
When I checked the status with "rails db: migrate: status" while making my own application,
I found a migration file that says "NO FILE".
Post as a memorandum how to delete because it is an unnecessary file!
[environment] ・ Ruby 2.6.5, Rails 6.0.0 ・ MacOS
% rails db:migrate:status
"NO FILE" is displayed when checking the status
Status Migration ID Migration Name
--------------------------------------------------
up 20201201125021 Remove name from tweets
up 20201202142455 Create comments
up 20201206104547 ********** NO FILE **********
Enter the following command
% vim db/migrate/(migration_file_id)_tmp.rb *in this case"20201206104547"
class Tmp < ActiveRecord::Migration
def change
end
end
Check the status again
% bundle exec rake db:migrate:status
It changes to the "Tmp" you entered earlier
Status Migration ID Migration Name
--------------------------------------------------
up 20201201125021 Remove name from tweets
up 20201202142455 Create comments
up 20201206104547 Tmp
Change status to down
% bundle exec rake db:migrate:down VERSION=(migration_file_id)
Status Migration ID Migration Name
--------------------------------------------------
up 20201201125021 Remove name from tweets
up 20201202142455 Create comments
down 20201206104547 Tmp
delete
% rm -rf db/migrate/20150708134153_tmp.rb
Finally check the status
% bundle exec rake db:migrate:status
Status Migration ID Migration Name
--------------------------------------------------
up 20201201125021 Remove name from tweets
up 20201202142455 Create comments
It has disappeared!