Skip to content

IBX-11939: Added Doctrine Migrations for the user-invitation schema#130

Open
Steveb-p wants to merge 8 commits into
base/ibx-11939-4.6-5.0-merged-6.0from
feature/schema-migration-6.0
Open

IBX-11939: Added Doctrine Migrations for the user-invitation schema#130
Steveb-p wants to merge 8 commits into
base/ibx-11939-4.6-5.0-merged-6.0from
feature/schema-migration-6.0

Conversation

@Steveb-p

@Steveb-p Steveb-p commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Warning

This PR's base branch (base/ibx-11939-4.6-5.0-merged-6.0) is not the real 6.0 branch — it's 6.0 with the 4.6 (#128) and 5.0 (#129) feature branches merged in. This PR intentionally shows only the changes introduced on top of "4.6 and 5.0, once merged forward" — review #128 and #129 first. Once those merge for real and are merged forward into 6.0, this PR's base will be updated to point at the real 6.0 branch.

Warning

This is the 6.0 follow-up to #129 (5.0). Review that PR first — this carries the same migration forward onto this branch.

🎫 Issue IBX-11939

Related PRs:

Package 4.6 5.0 6.0
ibexa/activity-log #166 #167 #168
ibexa/cart #172 #173 🔄 #174
ibexa/collaboration #115 #116
ibexa/connector-ai #198 #199
ibexa/core #785 #787 🔄 #788
ibexa/corporate-account #369 #370 🔄 #371
ibexa/discounts #341 #342
ibexa/discounts-codes #50 #51
ibexa/doctrine-migrations #1 #2 #3
ibexa/doctrine-schema #41 #42 #43
ibexa/fieldtype-page #208 #209 🔄 #210
ibexa/form-builder #240 #241 🔄 #242
ibexa/measurement #133 #134 🔄 #135
ibexa/messenger #22 #23
ibexa/migrations #438 #439 #440
ibexa/order-management #188 #189 🔄 #190
ibexa/payment #204 #205 🔄 #206
ibexa/product-catalog #1543 #1544 🔄 #1545
ibexa/product-catalog-date-time-attribute #53 #54
ibexa/product-catalog-symbol-attribute #17 #18
ibexa/scheduler #168 #169 🔄 #170
ibexa/segmentation #186 #187 🔄 #188
ibexa/share #190 #191
ibexa/shipping #154 #155 🔄 #156
ibexa/site-context #121
ibexa/site-factory #172 #173 🔄 #174
ibexa/user #128 #129 🔄 #130this PR
ibexa/workflow #191 #192 🔄 #193

🔄 = this branch adds an upgrade migration (renames/FK-retargets existing schema), not just a fresh baseline.

Description:

Adds InstallSchemaMigration (4.6.0 baseline, same as the 4.6 PR for this package) and RenameSchemaTo5_0Migration (tagged 5.0.0), renaming ibexa_user_invitations/ibexa_user_invitations_assignments to singular form. SQL sourced from ibexa/installer's shipped upgrade script (upgrade/db/{mysql,postgresql}/ibexa-4.6.latest-to-5.0.0.sql); SQLite equivalent derived by hand (DROP INDEX+CREATE INDEX in place of RENAME INDEX, which SQLite doesn't support; FK constraint-name-only renames skipped as cosmetic since SQLite auto-updates FK/column references across the schema on RENAME TABLE/RENAME COLUMN).

Verification caught a gap in the installer's own script: it was missing the rename of the assignment table's Doctrine-hashed FK-backing index — the hash changes when its table is renamed (IDX_DA5A7872A35D7AF0IDX_9E1E6F70A35D7AF0), even though the current schema.yaml requires it — fixed here.

The existing schema.yaml + BuildSchema(Event)Subscriber are untouched.

For QA:

Ran both migrations end-to-end against a real SQLite connection; the resulting tables/indexes match a fresh ibexa:doctrine:schema:dump-sql --force-platform=sqlite of the current schema.yaml exactly.

Documentation:

N/A — internal installer implementation detail.

Steveb-p added 8 commits July 24, 2026 12:50
…0.0 rename)

Adds InstallSchemaMigration (4.6.0 baseline) and, on 5.0+,
RenameSchemaTo5_0Migration renaming ibexa_user_invitations(_assignments)
to singular. ibexa/installer's shipped upgrade SQL was missing the rename
of the assignment table's Doctrine-hashed FK-backing index (its hash
changes with the table name: IDX_DA5A7872A35D7AF0 -> IDX_9E1E6F70A35D7AF0)
- added that. SQLite equivalent derived and verified end-to-end - resulting
schema matches a fresh dump-sql of the current schema.yaml exactly.

Existing schema.yaml + BuildSchemaSubscriber left untouched.
…lines

composer.json was missing ibexa/doctrine-migrations (require + matching
VCS repository entry for its unreleased dev branch), causing "Class
Doctrine\Migrations\AbstractMigration not found" across static analysis,
unit tests, and browser tests - mirrors ibexa/core's own composer.json
pattern exactly (same dev-branch constraint per major version).

Also removes extra blank lines the generator scripts introduced (before
each } elseif and the up() method's closing brace) that php-cs-fixer's
no_extra_blank_lines rule flagged.
PostgreSQL's ALTER TABLE ... RENAME TO does not rename the backing
SERIAL sequence, so the id column's nextval() default kept pointing at
the pre-rename sequence name. Add the missing ALTER SEQUENCE statements.
Extends AbstractSqlMigration (added in ibexa/doctrine-migrations) instead of the plain
Doctrine AbstractMigration, replacing `$this->platform instanceof ...` checks with
isMySQL()/isPostgreSQL()/isSqlite(), and moving each platform Statement block out of the
PHP file into its own sql/*.sql file loaded via addSqlFile().

Mechanical, content-preserving change: every migration was run before and after against
all three platforms and the resulting SQL statement lists are byte-for-byte identical.
Call abortIfUnsupportedPlatform() as the first statement of up(), so
installs on a database this migration doesn't build SQL for fail loudly
instead of silently queuing zero statements.
Each statement now ends with `;`, matching ibexa:doctrine:schema:dump-sql's
own convention, so the files are directly executable via mysql/psql/sqlite3
CLI clients. addSqlFile() still splits on the delimiter and passes one
statement per addSql() call, unaffected by the trailing terminator.
…tions

Checks $schema (already the live, introspected database) before running,
and skipIf()s when the tables/columns/FK targets this migration would
create already exist -- so installs that built their schema the old way
(SchemaBuilderEvent) can adopt Doctrine Migrations without every migration
aborting or duplicating existing schema objects.
Doctrine Migrations only calls MetadataStorage::complete() (the write to
doctrine_migration_versions) when a migration's up() returns normally --
never when it throws SkipMigration. So every migration using skipIf() was
being silently re-evaluated on every future doctrine:migrations:migrate
run instead of being permanently recorded as applied, even though its
guard condition (the schema already being in place) never changes back.

Replaces every `$this->skipIf($condition, $message);` with
`if ($condition) { return; }`: up() now returns normally with zero queued
SQL when the guard fires, so the migration is correctly recorded as
executed (with a "did not result in any SQL statements" warning logged,
which is expected and harmless) and never re-evaluated again.

Verified end-to-end: fresh ibexa:install (schema_builder_event enabled)
followed by doctrine:migrations:migrate now records all 44 tagged
migrations in doctrine_migration_versions in one pass, and a second
migrate run does zero work at all ("Already at the latest version").
@Steveb-p
Steveb-p force-pushed the feature/schema-migration-6.0 branch from d81ff36 to 441302a Compare July 24, 2026 10:51
@Steveb-p
Steveb-p changed the base branch from 6.0 to base/ibx-11939-4.6-5.0-merged-6.0 July 24, 2026 10:51
@sonarqubecloud

Copy link
Copy Markdown

@Steveb-p
Steveb-p marked this pull request as ready for review July 24, 2026 12:18
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