Skip to content

IBX-11939: Renamed the PostgreSQL primary keys left with their 4.6 names - #161

Merged
Steveb-p merged 1 commit into
feature/schema-migration-5.0from
feature/schema-drift-5.0
Oct 8, 2026
Merged

Steveb-p merged 1 commit into
feature/schema-migration-5.0from
feature/schema-drift-5.0

Conversation

@Steveb-p

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

Copy link
Copy Markdown
Contributor

Note

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

Warning

Schema drift between migrated and fresh 5.0 databases, fixed here by new migrations. A 5.0 database built through Doctrine Migrations, whether installed fresh or upgraded from 4.6, differs from a fresh SchemaBuilderEvent install in the names and definitions listed below.

🎫 Issue IBX-11939

Related PRs:

Description:

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

  • On PostgreSQL, the primary keys keep their 4.6 names, such as ibexa_user_invitations_pkey on ibexa_user_invitation. PostgreSQL keeps a renamed table's constraint names, and RenameSchemaTo5_0Migration renames the tables, not the primary keys. RenamePostgreSqlPrimaryKeysMigration renames all 2 to <table>_pkey, as PostgreSQL names them when it creates the tables. The renames are plain statements in sql/rename-primary-keys-postgresql.sql; a database has either all the 4.6 names or none, so the migration checks the first one.

ibexa/installer's upgrade scripts don't fix any of this either, so a site upgraded the old way has the same differences. 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, as on a fresh SchemaBuilderEvent install that runs the migrations afterwards.

Locally, with every package's follow-up applied, on MySQL 8.0, MariaDB 10.11 and PostgreSQL 16: a fresh install through migrations, a fresh SchemaBuilderEvent install migrated afterwards, and 4.6 installs from both paths upgraded to 5.0 all give the same schema as a fresh SchemaBuilderEvent install, by Doctrine DBAL's comparison and with the same constraint and index names.

PostgreSQL keeps a renamed table's constraint names, so the 5.0 table renames
left the primary keys with their 4.6 names, both on a fresh install through
Doctrine Migrations and on a database upgraded from 4.6. A fresh install
through the schema builder names them after the 5.0 tables.
@Steveb-p
Steveb-p force-pushed the feature/schema-drift-5.0 branch from f31c02e to 0b40237 Compare October 6, 2026 12:19
@sonarqubecloud

sonarqubecloud Bot commented Oct 6, 2026

Copy link
Copy Markdown

@Steveb-p
Steveb-p added this pull request to stack #163 October 7, 2026 12:20
@Steveb-p
Steveb-p marked this pull request as ready for review October 7, 2026 13:10
@Steveb-p
Steveb-p merged commit 0b40237 into 5.0 Oct 8, 2026
16 checks passed
@Steveb-p
Steveb-p deleted the feature/schema-drift-5.0 branch October 8, 2026 13:01
Steveb-p added a commit that referenced this pull request Oct 8, 2026
…mes (#161)

* IBX-11939: Renamed the PostgreSQL primary keys left with their 4.6 names

PostgreSQL keeps a renamed table's constraint names, so the 5.0 table renames
left the primary keys with their 4.6 names, both on a fresh install through
Doctrine Migrations and on a database upgraded from 4.6. A fresh install
through the schema builder names them after the 5.0 tables.
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.

3 participants