Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails迁移中的PostgreSQL表关系问题_Ruby On Rails_Postgresql_Pg - Fatal编程技术网

Ruby on rails Rails迁移中的PostgreSQL表关系问题

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,

当我运行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
生成模型,所以在我拥有的
属于:match
的模型和我拥有的
t.references:match
迁移文件中。我将所有所属对象切换为:match\u id,并更改了迁移文件
match\u id:integer
运行rails db:reset


但它仍然不起作用:(

在创建
匹配项之前,您尝试创建
picks
表。lol起作用了。使用
匹配:引用
安全吗?您的意思是
t.references:match
语法吗?