What to do when you want to delete a migration file that is "NO FILE"


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!

Recommended Posts

What to do when you want to delete a migration file that is "NO FILE"
What to do when rails creates a 〇〇 2.rb file
Completely delete the migration file that you failed to delete
What to do when rbenv says that there is no readline or lib history
What to do if you are told "there is no main manifest attribute" when creating a jar file containing dependencies in a maven project
How to delete the migration file NO FILE
What to do when a javax.el.PropertyNotWritableException occurs
What to do when you become a Problem During Content Assist
What to do when you run into a docker-compose node_modules problem
What to do when you want to know the source position where the method is defined in binding.pry
What do you use when converting to String?
Rails "How to delete NO FILE migration files"
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you get a SQLite3 :: BusyException: database is locked error
<f: ajax> Unable to attach <f: ajax> to non-ClientBehaviorHolder What to do when you become a parent
What to do when is invalid because it does not start with a'-'
What to do if you accidentally create a model
What to do when a null byte error occurs
ParseException: What to do when Unparseable date is reached
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What is a jar file?
What to do if you get a port error when docker-compose up on Mac
[Rails] What to do when you want to generate an error that cannot be destory when foreign key restrictions are applied
What to do if you get a java.io.IOException in GlassFish
What to do when you launch an application with rails
Delegate is convenient to use when you want to reuse parts
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
What you need to do to open a file from the menu in the document-Based App macOS app
[Rails] What to do when the view collapses when a message is displayed with the errors method
[Maven] What to do if you are asked to incorporate a jar that is not in the remote repository into the war
[Beginner] How to delete NO FILE
What to do when javax.batch.operations.JobStartException occurs
What to do when an UnsupportedCharsetException occurs in a lightweight JRE
What to do if you get a gcc error in Docker
ProxyFactory is convenient when you want to test AOP in Spring!
What to do if you get a DISPLAY error in gym.render ()
When you receive a call, send an SMS to that number
What to do if you cannot roll back the migration (UnknownMigrationVersionError)
Object-oriented design that can be used when you want to return a response in form format
What to do if you get a JNI shared library error when trying to build in Eclipse
[Java] What to do if a lot of "File is opened too much" is displayed due to FileNotFoundException
What to do about the "cannot be read or is not a valid ZIP file" error
[Output] Learn Ruby from what you want to do at the fastest speed-Part 2 "Create a flowchart"
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
A memo when you want to clear the time part of the calendar
[IOS] What to do when the image is filled with one color
What is a Spring Boot .original file?
When you want to add a string type column with a limited length with the `rails generate migration` command
What to do if you get a groovy warning in Thymeleaf Layout
How to delete the wrong migration file
What to do when "npm ERR! Code ENOSELF" is displayed after npm install
When you want Rails to disable a session for a specific controller only
What to do if you get Application with name appName is already registered. When you try to start GlassFish
What to do if zip dies if there is a pom when making an executable jar with gradle
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
If you want to make a zip file with Ruby, it's rubyzip.
[Swift] If you want to use a URL that includes Japanese, use addingPercentEncoding.
What to do if you get an error when you hit Heroku logs