feat: prep db identifiers for cross-platform (Postgres) portability#444
Merged
Conversation
- Rename 15 `changed_idx` indexes to `<table>_changed_idx` (Postgres scopes index names schema-wide; MariaDB scopes per-table — the shared name collides on Postgres). - Quote `user` table identifier in entity metadata (`#[ORM\Table(name: '`user`')]`). Doctrine emits the platform-native quote on every reference (`` `user` `` on MariaDB, `"user"` on Postgres), so no table rename is needed. - Add `validate-doctrine-schema-postgres` CI job that applies entity metadata to a Postgres 16 service container via `doctrine:schema:update --force --complete` and then runs `doctrine:schema:validate`. Gates against future entity-level Postgres regressions. Lands on 2.7 so the consolidated 3.0 migration (#441 / #442) can emit the portable shape from the start, keeping `migrations:rollup` honest for 2.x → 3.0 upgraders. Verified locally on MariaDB: migration applies cleanly, `doctrine:schema:validate` in sync, full PHPUnit suite green (133 tests / 516 assertions, identical to pristine release/2.7.0). Verified on Postgres 16: `doctrine:schema:update --force --complete` applies the metadata in 265 queries, `doctrine:schema:validate` in sync. down/up cycle of the new migration also verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
turegjorup
marked this pull request as ready for review
May 27, 2026 09:52
…y-prep-rename # Conflicts: # CHANGELOG.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
tuj
approved these changes
May 27, 2026
turegjorup
added a commit
that referenced
this pull request
May 27, 2026
Picks up #444's portability fixes (15 changed_idx index renames and backtick-quoted user table) into the consolidated end-of-2.8 schema so fresh 3.0 installs and 2.x → 3.0 rollups land on the same DDL the 2.x → 2.8 → 3.0 upgrade path produces via Version20260507120000. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 27, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Targets
release/2.8.0. Lands here so the consolidated 3.0 migration in #441 / #442 can be regenerated against the portable entity shape andmigrations:rollupstays honest for 2.x → 3.0 upgraders.Why
Two things in the current schema are MariaDB-only and block fresh Postgres installs:
changed_idxindex name reused on 15 tables. MariaDB scopes index names per-table; Postgres scopes them schema-wide, so the secondCREATE INDEX changed_idxcollides withrelation "changed_idx" already exists.usertable is reserved in standard SQL and in Postgres. Doctrine doesn't auto-quote it, so generated DML likeINSERT INTO user (...)is a syntax error on Postgres.Without resolving these on 2.8, the consolidated 3.0 migration can't emit a Postgres-portable shape — it has to match what 2.x → 3.0 upgraders' MariaDB already has, or
migrations:rolluplies. Fixing the divergence on 2.8 first means upgraders converge to the portable shape before they ever touch 3.0.What
Version20260507120000—RENAME INDEX changed_idx TO <table>_changed_idxon the 15 affected tables (feed,feed_source,media,playlist,playlist_screen_region,playlist_slide,screen,screen_campaign,screen_group,screen_group_campaign,screen_layout,screen_layout_regions,slide,template,theme). Reversible. No-op for MariaDB at runtime.#[ORM\Index(name: 'changed_idx')]updated to<table>_changed_idx;Userentity gets#[ORM\Table(name: '\user`')]` so Doctrine emits the platform-native quoted identifier on every reference.validate-doctrine-schema-postgresjob inpr.yamlspins up a Postgres 16 service container, applies entity metadata viadoctrine:schema:update --force --complete, then runsdoctrine:schema:validate. Catches future entity changes that break Postgres compatibility.Why backtick-quote
userinstead of renaming itA rename (
user→app_user) was the first approach considered but it requires touching every table that FKs intouser, plus realigning Doctrine's auto-derived hash-based index names (UNIQ_8D93D649…→UNIQ_88BDF3E9…). Backtick-quoting the identifier in the entity attribute is the standard Doctrine mechanism for reserved words: zero schema change, Doctrine emits`user`on MariaDB and"user"on Postgres from the same metadata. Trade-off accepted: any raw SQL outside Doctrine that hardcodesuserwould still need quoting on Postgres — but the only known instances (MultiTenantRepositoryTrait,RelationsChecksumCalculator) are deferred MariaDB-only paths called out in #442's "Out of scope" section anyway.Test plan
doctrine:migrations:migrateapplies all 26 migrations cleanly;doctrine:schema:validateis in sync; full PHPUnit suite green (133 tests / 516 assertions, byte-identical to pristinerelease/2.7.0baseline this PR was originally cut from).doctrine:schema:update --force --completeapplies entity metadata in 265 queries;doctrine:schema:validateis in sync;usertable is created, nochanged_idxcollision.release/2.8.0baseline after retarget.Follow-ups (not in this PR)
Version20260506215847in Consolidate 25 historical 2.x migrations into one end-of-2.8 schema #441 against the new entity shape so 3.0 fresh installs (on MariaDB or Postgres) emit the portable form. Rewrite migrations to Doctrine Schema tool + PHPStan enforcement #442's Schema-tool conversion stays intact — the regenerated DDL just uses the new index/identifier names.MultiTenantRepositoryTraitandRelationsChecksumCalculator(deferred per Rewrite migrations to Doctrine Schema tool + PHPStan enforcement #442 description) still blocks Postgres at runtime; those need a separate conversion before Postgres becomes a real install target.🤖 Generated with Claude Code