Skip to content

IBX-11939: Turned the PostgreSQL SERIAL columns into identity columns - #866

Draft
Steveb-p wants to merge 1 commit into
feature/fix-schema-rename-migration-6.0-postgresfrom
feature/schema-drift-6.0
Draft

Steveb-p wants to merge 1 commit into
feature/fix-schema-rename-migration-6.0-postgresfrom
feature/schema-drift-6.0

Conversation

@Steveb-p

@Steveb-p Steveb-p commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Note

Stacked on #788: it targets #788's branch and lands right after it.

Warning

Schema drift between migrated and fresh 6.0 databases, fixed here. A 6.0 database built through Doctrine Migrations, installed fresh or upgraded from 5.0, differs from a fresh SchemaBuilderEvent install, mostly because Doctrine DBAL 4 writes some things differently from the 4.6 and 5.0 install migrations.

The PostgreSQL SERIAL → identity conversion is a migration and a commit of its own (ConvertPostgreSqlSerialColumnsToIdentityMigration), so it's easy to spot, or to drop to keep SERIAL columns, which work the same for inserts.

🎫 Issue IBX-11939

Related PRs:

Description:

A fresh 6.0 install through Doctrine Migrations, and a 5.0 database upgraded with them, end up with the same schema. It differs from a fresh install through SchemaBuilderEvent here:

  • Identity columns (ConvertPostgreSqlSerialColumnsToIdentityMigration): on PostgreSQL, Doctrine DBAL 4 creates autoincrement columns as GENERATED BY DEFAULT AS IDENTITY, where the 4.6 and 5.0 install migrations made these 34 SERIAL. A PL/pgSQL block in sql/convert-serial-columns-to-identity-postgresql.sql turns each into an identity column that carries on from its sequence's current value, and drops the old sequence.

Each migration keeps its SQL in sql/*.sql files, so it can be read or run by hand; the PHP only checks whether it's needed, and does nothing where the database already matches.

Locally, with every package's 6.0 work and the 5.0 work merged up as the merge-ups will, on MySQL 8.0, MariaDB 10.11 and PostgreSQL 16: a fresh install through migrations, a fresh SchemaBuilderEvent install migrated afterwards, and 5.0 databases from both install paths upgraded to 6.0 all give the same schema as a fresh SchemaBuilderEvent install, by Doctrine DBAL's comparison and by constraint, index and column name. The only difference left is ibexa/messenger's composite index name. The upgrades need ibexa/doctrine-migrations#23.

Doctrine DBAL 4 creates autoincrement columns on PostgreSQL as GENERATED BY
DEFAULT AS IDENTITY, where the 4.6 and 5.0 install migrations created SERIAL
ones. This is a migration of its own, so it can be left out to keep SERIAL.
@Steveb-p
Steveb-p force-pushed the feature/fix-schema-rename-migration-6.0-postgres branch from 208d6b0 to ffc1f3b Compare October 8, 2026 19:43
@Steveb-p
Steveb-p force-pushed the feature/schema-drift-6.0 branch from 81457a9 to 4bad2a7 Compare October 8, 2026 19:43
@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant