LoginSignup
0
0

More than 3 years have passed since last update.

カラム名間違いでmigrationファイル差し戻し(最新のテーブルしかロールバックできない)

Posted at

あまりやらないので気をつけないといけないことがあります。

マイグレーションファイルはrials db:migrate:statusしても

terminal
database: furima_32844_development

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20210409081355  Devise create users
   up     20210414110750  Create items
  down    20210415131442  Create active storage tablesactive storage

3テーブルあったら最新で作った1テーブル分のファイルしかロールバックできない。

解決方法

STEP=nを付け加えればいいだけです。

rails db:rollback STEP=1

terminal
 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20210409081355  Devise create users
  down    20210414110750  Create items
  down    20210415131442  Create active storage tablesactive storage
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