0
私のレールアプリケーションでは、複数のpostgresqlスキーマがあります。Rails Postgresスキーマはロールバックの問題を参照します。
SHOW search_path;
search_path
--------------
"$user",public,vehicle
ビークルスキーマに2つのテーブル(ディーラー、在庫品)があります。
dealer has_many inventories
inventory belongs_to dealer
として、私は関係を追加するには、移行を作成しました::私が実行したときに、この移行は完璧に動作
class AddDealerIdToVehicleInventories < ActiveRecord::Migration
def change
add_reference 'vehicle.inventories', :dealer, index: true, foreign_key: {on_delete: :cascade}
end
end
:関係はこのように保持しているrake db:migrate
、FOREIGN_KEYは、いかなる問題なく表に追加思わ。私はミスをしたり、レールの移行バグでいた場合
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "vehicle.dealer_id" referenced in foreign key constraint does not exist
: ALTER TABLE "vehicle"."inventories" ADD CONSTRAINT "fk_rails_95ee16593d"
FOREIGN KEY ("vehicle.dealer_id")
REFERENCES "vehicle"."dealers" ("id")
ON DELETE CASCADE
私はわからない:私はrake db:rollback
を実行したときしかし、私はこのエラーメッセージを取得しています。助けてくれてありがとう。