rails db:migrate
データーベースを作るの意味
rails db:rollback
データーべースに作ったカラム(名前)などの追加や編集をしたい場合にロールバックをして1度戻す
その後再度rails db:migrate をする
そして今回のエラーですが
db>migrate内にあるactiverecord内で
def change
create_table :addresses do |t|
t.string :zip_code, null: false
t.references :region_of_shipping_origin_id, null: false
t.string :city, null: false
t.string :street_address, null: false
t.string :apartment_name, null: false
t.string :tel, null: false
t.references :order, null: false, foreign_key: true
t.timestamps
end
当初t.references :region_of_shipping_origin_id, null: false,foreign key
と書いておりましたがなぜかマイグレーションができませんでした。
原因はreferences ではなくintegerが正解だったみたい。ちなみに外部キーもいりません!
ちなみに マイグレーションの状況を確認するには
ターミナルにrails db:migrate:status
コマンドでマイグレーションファイルの状況を確認します。