我运行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:integer
和ran rails db:reset
但它仍然无法工作:(