简体   繁体   中英

Doctrine alter table causes auto_increment resequencing

I'm trying to execute the update schema command on doctrine, but the operation is not completed because the follow error:

Command executed:

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

Error:

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

But the table on question at present don't have auto_increment. So, Doctrine are inserting auto_increment on my table without my will?

How I can pass for this error without insert auto_increment in my table?

I resolved the problem!

I removed the @ORM\\GeneratedValue(strategy="IDENTITY") annotation property of the respective attribute of the entity.

See the examples below:

Before:

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

After:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM