Completely delete the migration file that you failed to delete

There is a mysterious migration file and it feels uncomfortable, so I will investigate how to erase it and write something refreshing.

Current status of migration files

rails db:migrate:status

I should have deleted the migration file

20200929181946.png

NO FILE remains like this.

NO FILE means that the migration file should have been deleted but remains on the computer. I feel uncomfortable, so I'll erase it.

rails db:rollback

--This will change the status part from up to down. (It can be edited) --Restore this empty file with a name

touch command

touch db/migrate/20200929050736_hoge.rb

aa.png This will restore a migration file called hoge. However, nothing is written in this file, so describe it appropriately. Add the following sentence in its entirety


class Hoge < ActiveRecord::Migration[6.0]
  def change
  end
end

Run rails db: migrate

rails db:migrate

When you reach here, you are ready to erase it. However, since the status remains up, it needs to be down to turn it off.

rails db:rollback

iiii.png

It became down. Command to erase here

rm -rf db/migrate/20200929050736_Hoge.rb

Let's check again with rails db: migrate: status

You have now completely erased the files you missed.

Recommended Posts

Completely delete the migration file that you failed to delete
How to delete the wrong migration file
How to delete the migration file NO FILE
[Rails] Delete the migration file
What to do when you want to delete a migration file that is "NO FILE"
Solution if you delete the migration file in the up state
Rails "How to delete NO FILE migration files"
The migration file is duplicated
[PostgreSQL] The story that you have to cut the session properly
Add Extended Attributes to the file
[PostgreSQL] If you want to delete the Rails app, delete the database first!
[Beginner] How to delete NO FILE
How to add the delete function
What to do if you cannot roll back the migration (UnknownMigrationVersionError)
To you who lament that the conversion of JODConverter + LibreOffice is slow
A story that was embarrassing to give anison file to the production environment
Migration file to add comment to Rails table
[Java] How to use the File class
Try changing the .erb file to .slim
Migration from Eclipse to IntelliJ (on the way)
[For beginners] How to implement the delete function
When you want to use the method outside
How to delete the database when recreating the application
Double-click to open the jar file on Windows
Introduce docker to the application you are creating
[Spring Boot] How to refer to the property file
How to delete the tweet associated with the user when you delete it at the same time
If you use SQLite with VSCode, use the extension (how to see the binary file of sqlite3)
The story that did not disappear when I tried to delete mysql on ubuntu
The CSV file that I was able to download suddenly started to appear on the page.
Create an app that uses the weather API to determine if you need an umbrella.