rails6 migrateのstatusをdownからupに変更する

rails6でmigrateのstatusをdownからupに変更するまでの手順を記述してます。Railsのバージョンは6.1.1を使用してます。
環境
- OS CentOS Linux release 7.9.2009 (Core)
- Ruby 2.7.2
- Rails 6.1.1
- rbenv 1.1.2-40-g62d7798
upに変更
まずは、「Migration ID」を以下のコマンドで確認します。
rails db:migrate:status

IDが確認できれば、「VERSION」にIDを指定して「up」に変更します。
rails db:migrate:up VERSION=20210126085907
以下が発生する場合は、
== 20210126085907 CreateSamples: migrating ====================================
-- create_table(:samples)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::DuplicateTable: ERROR: リレーション"samples"はすでに存在します
migrationファイルを以下のように編集すれば「up」に変更されます。
class CreateSamples < ActiveRecord::Migration[6.1]
def change
end
end

-
前の記事
windows PCの購入時期を調べる 2021.06.18
-
次の記事
GitKrakenでファイルの変更を元に戻す 2021.06.18
コメントを書く