Ruby on rails Rails迁移中的PostgreSQL表关系问题
当我运行heroku run rails db:migrate时,我遇到了这个错误Ruby on rails Rails迁移中的PostgreSQL表关系问题,ruby-on-rails,postgresql,pg,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,
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
生成模型,所以在我拥有的属于:match
的模型和我拥有的t.references:match
迁移文件中。我将所有所属对象切换为:match\u id,并更改了迁移文件match\u id:integer
和运行rails db:reset
但它仍然不起作用:(在创建
匹配项之前,您尝试创建picks
表。lol起作用了。使用匹配:引用
安全吗?您的意思是t.references:match
语法吗?