Just a simple example: If I want create a table with auto fill id in postgres I run this sql:
CREATE SEQUENCE person_id_seq START 1;
CREATE TABLE person (
I encountered this problem today and I found that:
IDENTITY work good, because it uses SERIAL type for PostgreSQL, which automatically creates related sequence and set default value as nextval(sequence)
AUTO creates table and then related sequence, but doesn't set default value for id column. It can be set by adding following code:
/**
* Webpage's ID
*
* @ORM\Id
* @ORM\Column(type="integer", options={"default"="nextval('webpages_id_seq'::regclass)"})
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $id;
but unfortunately Doctrine create table first, so we need to swap SQL code creating table and sequence in order that sequence will be created first
SEQUENCE works the same as AUTO