…ma and data install path (inlined SQL) (#788)
* IBX-11939: Adapted the Doctrine Migrations install path to 6.0
What the 5.0 work needs on 6.0's stack:
- DBAL 4 removed AbstractPlatform::getName() and AbstractSchemaManager::createSchema():
CoreInstaller::reportExecutedQueries() uses getDBMSDataDirectoryName() like the rest of the
class, and TaggedMigrationsRunner introspects the live schema via createSchemaManager()->
introspectSchema().
- 6.0's PHPStan rules want arrow function return types (OrmEntitiesSchemaSubscriber and its test)
and static createStub() calls.
- PHPUnit 11 metadata as attributes instead of doc-comment annotations in the RepositoryInstaller
tests this effort added.
* IBX-11939: Lifted the schema assets filter for TaggedMigrationsRunner's introspection
6.0's ManagedTablesSchemaAssetFilter hides every table without an ORM entity behind it from
schema introspection. The Schema handed to each migration came from that filtered introspection,
so the migrations' hasTable() guards saw almost nothing - ImportDataMigration concluded the
baseline tables didn't exist and skipped importing the bootstrap data, leaving an empty
repository. The runner now introspects through SchemaAssetsFilterBypassInterface, the same way
CoreInstaller lists existing tables.
* IBX-11939: Added the 6.0 content version constraints migration
Core's part of the 5.0 to 6.0 schema change (IBX-12078), converted from ibexa/installer's
upgrade/db/{mysql,postgresql}/ibexa-5.0.latest-to-6.0.0.sql: "ibexa_content_version.contentobject_id"
becomes mandatory, with a unique (contentobject_id, version) index replacing the plain one. Versions
without a content item are orphans and are removed first. SQLite can't add NOT NULL in place, so
there the table is rebuilt.
Skipped when the unique index already exists, i.e. on schemas installed through SchemaBuilderEvent.
* IBX-11939: Adapted TaggedMigrationsRunnerTest to 6.0
Passes the runner its SchemaAssetsFilterBypass, uses DBAL 4's
createSchemaManager() and PHPUnit 11's CoversClass attribute, and covers the
bypass itself: a migration whose guard needs a table the connection's schema
assets filter hides only runs when the filter is lifted.
* IBX-11939: Replaced SqlPlatform with doctrine-schema's DatabasePlatformName
* IBX-11939: Added MariaDB to the platforms the 6.0 migrations support
doctrine-migrations 6.0 takes SqlPlatform now, so the migrations that only exist on this
branch list SqlPlatform::MARIADB and run their MySQL SQL there too, like the ones from 4.6.
* IBX-11939: Converted the MariaDB JSON columns an earlier install created to 6.0's form
On MariaDB, InstallSchemaMigration creates JSON columns as LONGTEXT with a "(DC2Type:json)"
comment on 4.6, as JSON with that comment on 5.0, and as JSON without it on 6.0, as Doctrine DBAL
2.13, 3 and 4 do. It's the same migration, so it doesn't run again on a database upgraded to 6.0,
and those columns kept their earlier form. ConvertMariaDbJsonColumnsTo6_0Migration converts them
to 6.0's definition. It skips columns already in that form, so a fresh 6.0 install is unaffected.
ibexa/installer's upgrade scripts don't change these columns either. A database upgraded through
them gets them converted once it runs the Doctrine Migrations.
* IBX-11939: Moved the MariaDB JSON conversion's SQL into a file
The column definitions were a constant in the migration class, and the
statements were built in PHP. They're plain SQL in sql/ now, so they can be
read or run by hand; the class only checks whether the last column is
converted yet and loads the file if it isn't.
* IBX-11939: Dropped the already-converted check from the MariaDB JSON conversion
Running the MODIFY statements on columns already in that shape changes nothing,
and MariaDB does it as an instant, metadata-only change, so the check bought
nothing. Raised in review on ibexa/activity-log#167.
Warning
Stacked on the
5.0→6.0merge-up #877. Its base branch (merge/5.0-to-6.0) is6.0with5.0merged in, so this PR shows only what 6.0 needs on top. Fast-forward #877 into6.0first, then retarget this PR to6.0.Warning
This is the 6.0 follow-up to #787 (5.0). Review that PR first — this adapts it to 6.0's stack.
Warning
MariaDB schema drift between upgraded and fresh installs, fixed here by a new migration. On MariaDB,
InstallSchemaMigrationcreatesibexa_setting.valueasLONGTEXT … COMMENT '(DC2Type:json)'on 4.6, asJSON … COMMENT '(DC2Type:json)'on 5.0, and as plainJSONon 6.0, as Doctrine DBAL 2.13, 3 and 4 do. It doesn't run again on upgrade, and ibexa/installer's upgrade scripts don't change it either, so a 4.6 or 5.0 database upgraded to 6.0 kept its earlier form.ConvertMariaDbJsonColumnsTo6_0Migrationconverts it to 6.0's definition, and fails if a row holds invalid JSON. On MariaDB 10.11, 4.6 and 5.0 databases upgraded to 6.0 end up identical to a fresh 6.0 install, data included; on a fresh install or a re-run it states the same definition again, which changes nothing (MariaDB makes it an instant, metadata-only change), and on other databases it does nothing. The 5.0 counterpart,ConvertMariaDbJsonColumnsMigration, is in #787.Note
Test-side companion —
ibexa/test-core#57.Moves the baseline fixture import into its own
BaseFixtureHook(priority 950, between theschema hooks and
FixtureHook), switchable with aload_base_fixtureoption.It matters here because under the Doctrine Migrations path the baseline repository content
arrives as core's
ImportDataMigrationrather than as a loaded fixture, andFixtureImportertruncates every table a fixture touches before inserting — so a package's own fixture writing
into those tables would take the baseline's rows with it unless it implements
AppendOnlyFixture.Packages whose integration tests load their own fixtures depend on it; the rest are unaffected.
Note
Shared library —
ibexa/doctrine-migrations.Every migration in the table below extends the
AbstractSqlMigration/SqlPlatformbase it provides.It is already merged on all three branches, so nothing in this effort is blocked on it:
#1 (4.6 baseline) · #3 (6.0 baseline) · #4 (
enable_service_migrationsfix) · #6 (DBAL 4).The fix reached 5.0 and 6.0 via merge-ups #9 and #10 — which is why
#5was closed rather than merged.Related PRs:
#440⏭️#18⏭️#191⏭️🔄 = this branch adds an upgrade migration (renames/FK-retargets existing schema), not just a fresh baseline.
⚠️ = fixes a different, related problem (missing
🩹 = this branch also received a backported delta migration, converted from a legacy
ibexa/installerupgrade/db/*.sqlscript (4.6.0 or later) that the original baseline-only migration didn't cover. See IBX-11939 upgrade-scripts backport report or that package's own PR description for details.SchemaBuilderEventsupport for a plain Doctrine ORM entity/table) — not a Doctrine Migrations baseline/upgrade migration like the rest of this table. See that package's own PR description for details.⏭️ =
struck throughand closed as unnecessary — that tier needs no changes of its own. Everything it requires arrives through the normal merge-up from the tier below; the branch is kept, so the PR can be reopened if genuinely tier-specific work turns up.Description:
Carries #787 onto 6.0. Most of it arrives through the base branch - this PR is what 6.0's stack needed on top:
TaggedMigrationsRunnerruns each migration through Doctrine's Migrator with the connection's schema assets filter lifted, viaSchemaAssetsFilterBypassInterface. 6.0'sManagedTablesSchemaAssetFilterhides every table without an ORM entity behind it, so theSchemathe executor introspects for each migration was nearly empty:ImportDataMigration'shasTable()guard concluded the baseline tables weren't there and skipped the bootstrap data, leaving an empty repository after a Doctrine Migrations install.CoreInstalleralready bypasses the filter the same way when listing existing tables.TaggedMigrationsRunnerTestcovers it: a migration whose guard needs a table the filter hides only runs with the filter lifted.AbstractPlatform::getName()andAbstractSchemaManager::createSchema(), soCoreInstaller::reportExecutedQueries()usesgetDBMSDataDirectoryName()like the rest of the class. The runner's failure message names the failing statement, which DBAL 4 leaves out of its own.createStub()calls), and PHPUnit 11 attributes instead of doc-comment annotations in theRepositoryInstallertests this effort added.The base merge itself combines
CoreInstaller's constructor - 6.0's$schemaAssetsFilterBypass/$dbPlatformFactoryplus #787's$schemaBuilderEventEnabled/$taggedMigrationsRunner- and takes #787'sServiceLocator-basedInstallPlatformCommandin place ofInstallerTagPass.It also adds
AddContentVersionUniqueIndexMigration(tagged6.0.0), core's part of the 5.0→6.0 schema change (IBX-12078, fromibexa/installer'sibexa-5.0.latest-to-6.0.0.sql):ibexa_content_version.contentobject_idbecomesNOT NULL, with a unique(contentobject_id, version)index replacing the plain one. Versions without a content item are orphans and are deleted first. SQLite rebuilds the table, since it can't addNOT NULLin place. Skipped when the unique index already exists.For QA:
Ran taxonomy's and measurement's integration suites against this branch locally -
6.0with their 5.0 work merged in, on MySQL 8 and PostgreSQL 14, with bothschema_builder_eventvalues. Both pass on all four (taxonomy with its own 6.0 migration from ibexa/taxonomy#433). After a Doctrine Migrations install, core's tables now match the onesSchemaBuilderEventcreates on MySQL and PostgreSQL.To verify manually: set
ibexa.installer.schema_builder_event.enabled: false, runibexa:install, and check the repository has its bootstrap content (e.g. theadminuser) - before the filter bypass it came up empty.Documentation:
N/A — internal installer implementation detail.