0
有一个团队表在我的项目中。 我做了应该使用下面的命令来创建表匹配迁移:定义两个引用到另一个表中的同一列
rails generate model Match Team:references Team:re
ferences score1:integer score2:integer date:datetime length:integer place:string
我想我匹配表包含2个外键(TEAM1,TEAM2)引用同一列(id)上团队表。我敢肯定,我这样做是错误的,因为在schema.rb有:
create_table "matchs", force: true do |t|
t.integer "Team_id"
t.integer "score1"
t.integer "score2"
t.datetime "date"
t.integer "length"
t.string "place"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "matchs", ["Team_id"], name: "index_matchs_on_Team_id"
,我不能看到第二TEAM_ID。 什么是正确的方式来做我所需要的?
同一个表的两个'外键'?这怎么可能? – Pavan
为什么这不可能? – Patryk
你不能有两个'team_id's.Pubably你可以有'team_1_id'和'team_2_id'。 – Pavan