0
0

More than 1 year has passed since last update.

エラー対応:Migration Nameにて「NO FILE」

Posted at

エラー内容

modelを実装中、DBに不手際を確認。
該当ファイルを削除した結果、Migration Nameにて「NO FILE」のエラーを確認。
「rails db:rollback」を実施していないため、エラーが発生。

修正対応

  • migrationの状態を確認
rails db:migrate:status
  • 下記のmigrationを確認
Status   Migration ID    Migration Name
--------------------------------------------------
   up     20210726110200  Sorcery core
   up     20210726111347  Add columns to users
   up     20210804115220  Create boards
   up     20210804120214  Add user id to boards
   up     20210811081624  Add img to boards
   up     20210812091707  ********** NO FILE **********
  • Migration IDをコピペし、ダミーファイルを作成
terminal
touch db/migrate/20210812091707_hoge.rb
  • 20210812091707_hoge.rbに下記を記載
class Hoge < ActiveRecord::Migration[5.2]
  def change
  end
end
  • rails db:migrate:status を実行してMigration Nameが付与されていることを確認
Status   Migration ID    Migration Name
--------------------------------------------------
~ 
   up     20210812091707  Hog
  • 下記コマンドを実行して、migrationをdownにする
rails db:migrate:down VERSION=20210812091707
  • 再度、migrationの状態を確認
Status   Migration ID    Migration Name
--------------------------------------------------
~ 
   down     20210812091707  Hog
  • ステータスが「down」になっていれば完了。ダミーファイル「20210812091707_hoge.rb」を削除して完了

参考サイト

Ruby on Rails 『NO FILEのmigrationを削除する方法』

開発中の不手際により、失敗の備忘も兼ねて学習メモを作成。

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