1
1

More than 3 years have passed since last update.

主従関係とマイグレーション順番を合わせないといけない

Posted at

以下のdownのファイルをマイグレートしてテーブルを作ろうと思います。

Status Migration ID Migration Name

up 20210409081355 Devise create users
up 20210414110750 Create items
up 20210415131442 Create active storage tablesactive storage
down 20210424083734 Create addresses
down 20210424083812 Create purchases

何度やってもうまくいきません。

terminal
Caused by:
Mysql2::Error: Table 'furima_32844_development.purchases' doesn't exist

細かいことなんですが、
①MigrationID20210424083734のファイルが配送先住所ファイルで、
②MigrationID20210424083812が購入情報なので

①が子②が親でマイグレーションの順番を変えないとMigrationできないようです。

解決策1

最初についている長い名前のMigrationID番号を入れ替えるで解決します。

解決策2

% rails db:migrate:up VERSION=20210424083734

コマンドでMigrationするファイルを指定する

1
1
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
1
1