gpt4 book ai didi

php - Doctrine alter table 导致 auto_increment 重新排序

转载 作者:行者123 更新时间:2023-11-30 00:02:23 26 4
gpt4 key购买 nike

我尝试在 Doctrine 上执行更新架构命令,但操作未完成,因为出现以下错误:

执行的命令:

php doctrine orm:schema-tool:update --force

错误:

SQLSTATE[23000]: Integrity constraint violation: 1062 ALTER TABLE causes auto_increment resequencing, resulting in duplicate entry '1' for key 'PRIMARY'

但是目前有问题的表没有auto_increment。那么,Doctrine 会在未经我同意的情况下在我的表上插入 auto_increment 吗?

如何在不在表中插入 auto_increment 的情况下传递此错误?

最佳答案

我解决了问题!

我删除了实体相应属性的 @ORM\GenerateValue(strategy="IDENTITY") 注释属性。

请参阅下面的示例:

之前:

   /**
* @var integer
*
* @ORM\Column(name="id_usuario", type="smallint", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $idUsuario;

之后:

   /**
* @var integer
*
* @ORM\Column(name="id_usuario", type="smallint", nullable=false)
* @ORM\Id
*/
private $idUsuario;

关于php - Doctrine alter table 导致 auto_increment 重新排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24909813/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com