我有一个与表有两个关系(和)的Person
实体。这两个字段都可以为空,否则它们必须存在于表中:hometown
current
Location
Location
class Person {
.....
/**
* @var Location
* @ORM\OneToOne(targetEntity="Location")
* @ORM\JoinColumn(name="hometown_id", referencedColumnName="id",nullable=true)
**/
protected $hometown;
/**
* @var Location
* @ORM\OneToOne(targetEntity="Location")
* @ORM\JoinColumn(name="current_id", referencedColumnName="id", nullable=true)
**/
protected $current;
....
}
现在,我想根据doctrine:schema:update --dump-sql
输出更新我的数据库架构,但这会产生问题:
CREATE UNIQUE INDEX UNIQ_8D93D6494341EE7D ON person (hometown_id);
CREATE UNIQUE INDEX UNIQ_8D93D649B8998A57 ON person (current_id);
我无法定义这些索引,因为表中有多个空行。
你能帮帮我吗?