phppostgresqlsymfony

Why Symfony does not create sequence upon migration execution?


The problem was automatic ID generation for new records in postgresql entities despite declaring strategy as AUTO in GeneratedValue attribute - it did not generate the ids.

    #[ORM\Id]
    #[ORM\GeneratedValue(strategy: "AUTO")]
    #[ORM\Column]
    protected $id = null;

Solution

  • To fix this, you have to set a type for an id column:

        #[ORM\Id]
        #[ORM\GeneratedValue(strategy: "AUTO")]
        #[ORM\Column(type: 'integer')]
        protected $id = null;
    

    Create new migration, execute and after execution you should notice a new sequence in postgresql database sequences.