Skip to content

Conversation

@lucasmirloup
Copy link
Contributor

@lucasmirloup lucasmirloup commented Aug 26, 2025

Hello,
I'm currently updating Doctrine DBAL from version 3 to 4 on an app that uses Doctrine generated ID columns (with no strategy defined, thus using AUTO if I'm not mistaken) with PostgreSQL 17.

I suspect that the generation strategies' documentation for PostgreSQL is outdated or inaccurate, due to changes introduced in / for Doctrine DBAL 4.

Here's a more detailed report / explanation:

I initially encountered database errors about PostgreSQL's SEQUENCE, and tried tinkering with the strategy, to no avail.
I then stumbled upon the following documentation: https://github.com/doctrine/dbal/blob/4.3.x/docs/en/how-to/postgresql-identity-migration.rst

Still, something about the generation strategies' documentation confused me: the documentation claims that no matter Doctrine DBAL's version, the default (AUTO) strategy on PostgreSQL is SEQUENCE.

When tested on my app, either of these 2 lines produce the same database migrations:

#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\GeneratedValue]
ALTER TABLE my_table ALTER id DROP DEFAULT;
ALTER TABLE my_table ALTER id ADD GENERATED BY DEFAULT AS IDENTITY;

but the SEQUENCE strategy just seems to remove the DEFAULT:

#[ORM\GeneratedValue(strategy: 'SEQUENCE')]
ALTER TABLE my_table ALTER id DROP DEFAULT;

This behavior suggested that the default strategy on PostgreSQL would be IDENTITY and not SEQUENCE.

After digging into the code, it seems to be the case:

Thank you for reviewing my PR, tell me if there is anything wrong / that can be improved in it 👍
Thank you for all the work you did on Doctrine!

PS : Do these documentation changes need to be backported all the way back to ORM 3.0? The initial commit that introduced this difference seems to date back to ORM 3.0 RC 1: bdc039f

@greg0ire
Copy link
Member

Thanks for your PR, no need to backport this.

@greg0ire greg0ire added this to the 3.5.3 milestone Aug 27, 2025
@greg0ire greg0ire merged commit 200a505 into doctrine:3.5.x Aug 27, 2025
1 check passed
@greg0ire
Copy link
Member

Thanks @lucasmirloup !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants