Rails迁移中的PostgreSQL表关系问题

时间:2018-08-15 09:21:34

标签: ruby-on-rails postgresql pg

我运行heroku run rails db:migrate时遇到此错误。...

rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedTable: ERROR:  relation "matches" does not exist
: CREATE TABLE "picks" ("id" bigserial primary key, "week_score_id" bigint, "picked_team_id" bigint, "match_id" bigint, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_60b2712d81"
FOREIGN KEY ("week_score_id")
  REFERENCES "week_scores" ("id")
, CONSTRAINT "fk_rails_efd026f22b"
FOREIGN KEY ("match_id")
  REFERENCES "matches" ("id")
)

开发处于sqlite,生产处于pg

我猜是我的表关系不正确吗?

首先,我认为这个问题是因为我使用match:references生成模型,因此在模型中我拥有belongs_to :match,在迁移文件中我拥有t.references :match。我将所有属植物切换到:match_id,还更改了迁移文件match_id:integerran rails db:reset
但它仍然无法工作:(

0 个答案:

没有答案