Doctrine Auto Increment Starting Value @ORM\GeneratedValue

/**
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="SEQUENCE")
 * @ORM\SequenceGenerator(sequenceName="id", initialValue=250000)
 * @ORM\Column(type="integer")
 */
 protected $id;

http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html


Don't know this answer is useful to users or not. But for me its giving required result (for docrtine with mysql) I had used auto increment id as normally used,

/**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
private $id;

First time you run command to update than table will create. Than you should manually run below command to set custom initial auto increment id

ALTER TABLE users AUTO_INCREMENT=1001;

Again on running schema it will not update auto increment which is manually set. And thats it!! Its the desired result.


On MySQL platform, I write that (@ORM\Table(options={"auto_increment": 12345})) to add "AUTO_INCREMENT = 12345" to the SQL creation table. I didn't use @ORM\SequenceGenerator:

/*
 * @ORM\Table(options={"auto_increment": 12345})
 */
class MyEntity {

    /**
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     */
    private $id;

    // Others properties
}

And in the migration file:

    $this->addSql('CREATE TABLE my_entity (id INT AUTO_INCREMENT NOT NULL, ...) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB AUTO_INCREMENT = 12345');