0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

NOFILEを削除する

Last updated at Posted at 2023-03-10

git reset --hardでマイグレーションが消えた

**********@mbp ***** % bin/rake db:migrate:status                  

database: ********

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20221228045452  Create users
.
.
.
   up     20230308014904  ********** NO FILE **********
   up     20230308021103  ********** NO FILE **********
*********@mbp ***** % rails db:migrate:down VERSION=20230308014904
rails aborted!
ActiveRecord::UnknownMigrationVersionError: 

No migration with version number 20230308014904.

これをなんとか消したい。

IDが同じのダミーのマイグレーションファイルを作成する

touch db/migrate/20230308014904__hoge.rb

rails db:migrate

********@mbp ****** % bin/rake db:migrate:status              

database: ******_development

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20221228045452  Create users
.
.
.
   up     20230308014904  Hoge
   up     20230308021103  ********** NO FILE **********

IDが同じのファイルがダミーファイルが作成された。

*********@mbp ***** % rails db:migrate:down VERSION=20230308014904              
== 20230308014904 Hoge: reverting =============================================
== 20230308014904 Hoge: reverted (0.0068s) ====================================

ダウンになった。

*********@mbp ****** % bin/rake db:migrate:status               

database: ******_development

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20221228045452  Create users
.
.
.
  down    20230308014904  Hoge
   up     20230308021103  ********** NO FILE **********

これで削除できる

すごい!

出典

感想

英語だけでは不安だったので日本語も同じようなものがあってよかった。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?