7
5

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 3 years have passed since last update.

rails db:migrateがdbに反映されない場合の解決例

Posted at

rails db:migrateを行ってDBに反映されない場合は、
rails db:migrate:statusでステータスを確認します。

upの状態であれば,rails db:rollbackを行います。
rails db:rollbackは、テーブルを差し戻すという内容です。

その後、rails db:migrateを行うことでデータがdbに反映されます。

○○○○○○○○@○○○Air ○○○-3419 % rails db:migrate:status 

database: ○○○○○○_3419_development

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     20210218055220  Devise create users
   up     20210222081535  Create items

○○○○○○○@○○○Air ○○○-3419 % rails db:rollback      
== 20210222081535 CreateItems: reverting ======================================
-- drop_table(:items)
   -> 0.0172s
== 20210222081535 CreateItems: reverted (0.0205s) =============================

○○○○○○○@○○○Air ○○○-3419 % rails db:migrate       
== 20210222081535 CreateItems: migrating ======================================
-- create_table(:items)
   -> 0.0454s
== 20210222081535 CreateItems: migrated (0.0455s) =============================
7
5
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
7
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?