这是一种在实体中使用选项nullable=true, unique=true
?
我尝试这样做,并且在更新数据库架构时出错:
/**
* @var string
*
* @ORM\Column(name="code", type="string", length=16, nullable=true, unique=true)
*/
private $code;
控制台:
php bin/console doctrine:schema:update --force
Updating database schema...
[Doctrine\DBAL\Exception\UniqueConstraintViolationException]
An exception occurred while executing 'CREATE UNIQUE INDEX
UNIQ_6EEAA67DE76
8E439 ON commande (code)':
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry
'' fo
r key 'UNIQ_6EEAA67DE768E439'