Skip to content

IBX-12530: Rebuilt DatabaseSchemaHook on SchemaBuilderInterface instead of a raw-file reimplementation - #43

Merged
Steveb-p merged 3 commits into
4.6from
database-schema-hook-schema-builder
Sep 10, 2026
Merged

IBX-12530: Rebuilt DatabaseSchemaHook on SchemaBuilderInterface instead of a raw-file reimplementation#43
Steveb-p merged 3 commits into
4.6from
database-schema-hook-schema-builder

Conversation

@Steveb-p

@Steveb-p Steveb-p commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator
🎫 Issue IBX-12530

Description:

DatabaseSchemaHook used to import raw schema.yaml files (listed via SchemaFilesProviderInterface) through LegacySchemaImporter — a test-only importer that never dispatches SchemaBuilderEvent. So any package contributing its schema through that event rather than a schema.yaml (e.g. deriving it from Doctrine ORM mappings via SchemaTool) was never exercised by integration tests at all, even though the event is exactly what ibexa:install's legacy path relies on in production.

It now calls SchemaBuilderInterface::buildSchema() — the same production code — and applies the resulting Schema's SQL directly, since the test database is always freshly created. A test kernel no longer declares which schema files to load: whatever bundles it registers is what the schema contains.

That needs two bundles present: DoctrineSchemaBundle for SchemaBuilderInterface, and IbexaRepositoryInstallerBundle because core's own BuildSchemaSubscriber lives there rather than in IbexaCoreBundle — without it you get every other package's tables but none of core's. Rather than gate the registration, the hook is registered like any other and RemoveUnsatisfiableHooksPass drops it when either collaborator is absent. It checks for the services themselves (SchemaBuilderInterface, and RepositoryInstaller's BuildSchemaSubscriber) rather than for bundle names, and runs at the default compiler-pass priority — before AutowirePass, so removing the definition beats autowiring failing on it.

SchemaFilesProviderInterface and the rest of that chain (SchemaFilesKernelMethodProvider, SchemaFilesParameterProvider, SchemaFilesProviderChain, and the ibexa.test.schema_files parameter) only ever existed to feed this hook, so they're gone. DefaultSchemaFilesProvider stays: IbexaTestKernel::getSchemaFiles() is still mandated by IbexaTestKernelInterface, and ibexa/core's IbexaKernelTestTrait::loadSchema() reads it when a test calls it explicitly.

Downstream packages each need a small follow-up (register the two bundles, drop their own *SchemaFilesProvider); those land separately. #44 builds on this to let Bootstrapper accept a non-Ibexa kernel, reusing the same pass for the other built-in hooks.

For QA:

Checked against four packages spanning the range of Bootstrapper setups, each with its explicit schema file list removed:

Package setup result
ibexa/activity-log plain bootstrap(), 1 schema file 124 tests, unchanged
ibexa/taxonomy ORM-derived schema, no schema.yaml at all 34 tests, unchanged
ibexa/cart 3 schema files / 3 bundles, purge-index hook 86 tests, schema byte-identical
ibexa/order-management 5 schema files / 5 bundles, fixtures hook, migrations 163 tests, schema a superset

The order-management difference is worth a look: the event-driven schema additionally contains ibexa_user_invitations and ibexa_user_invitations_assignments (plus indexes and FK). Those come from ibexa/user's subscriber, and IbexaUserBundle is registered in that test kernel — the hand-maintained file list had just never included it. Diff was one-directional in both packages: nothing the file list produced went missing.

Also confirmed the pass behaves both ways: a full kernel keeps all four hooks, and ibexa/doctrine-migrations' minimal kernel (no ibexa/core at all) drops every one of them and still boots.

…-file reimplementation

Previously imported schema.yaml files listed by SchemaFilesProviderInterface via
LegacySchemaImporter -- a test-only mechanism that never actually dispatched
SchemaBuilderEvent, so any package's own event subscriber (e.g. one deriving its
schema from Doctrine ORM entity mappings instead of a schema.yaml file) was never
exercised by integration tests at all.

Now calls SchemaBuilderInterface::buildSchema() directly -- the same production
code ibexa:install's legacy path uses -- and applies the resulting Schema's SQL
directly, since the test database is always freshly created. No per-package
schema file list needed.

Only registered when DoctrineSchemaBundle is actually present (detected in
IbexaTestCoreBundle::build(), which runs against the real, shared container --
unlike Extension::load(), which runs against a temporary per-extension copy
MergeExtensionConfigurationPass uses to avoid cross-extension leakage, so sibling
bundles' extensions never show up there). Not registered by IbexaTestKernel by
default; a consuming package must register it itself to use this hook.
…chema-file provider chain

Registering only DoctrineSchemaBundle isn't enough: core's own schema contribution comes from
IbexaRepositoryInstallerBundle's BuildSchemaSubscriber, not IbexaCoreBundle, so without it the
SchemaBuilderEvent produces every package's tables but none of core's. Verified against
ibexa/cart, which failed on a missing ezcontentclass_attribute_ml until that bundle was added.

SchemaFilesProviderInterface and its whole chain (SchemaFilesKernelMethodProvider,
SchemaFilesParameterProvider, SchemaFilesProviderChain, and the ibexa.test.schema_files
parameter) existed solely to feed DatabaseSchemaHook, which no longer reads them -- removed.
DefaultSchemaFilesProvider stays: IbexaTestKernel::getSchemaFiles() is mandated by
IbexaTestKernelInterface and consumed by ibexa/core's own IbexaKernelTestTrait.
@Steveb-p
Steveb-p force-pushed the database-schema-hook-schema-builder branch from 2e50eac to cf1d81f Compare September 9, 2026 10:13
@Steveb-p
Steveb-p marked this pull request as ready for review September 9, 2026 12:00
@alongosz alongosz changed the title Rebuild DatabaseSchemaHook on SchemaBuilderInterface instead of a raw-file reimplementation Rebuilt DatabaseSchemaHook on SchemaBuilderInterface instead of a raw-file reimplementation Sep 9, 2026
Steveb-p added a commit to ibexa/user that referenced this pull request Sep 9, 2026
ibexa/test-core#43 rebuilds DatabaseSchemaHook on SchemaBuilderInterface::buildSchema()
instead of importing raw schema.yaml files, so the test kernel now has to register
DoctrineSchemaBundle (which provides SchemaBuilderInterface) and
IbexaRepositoryInstallerBundle (which holds core's own BuildSchemaSubscriber).
Steveb-p added a commit to ibexa/user that referenced this pull request Sep 9, 2026
Points CI at the branch that rebuilds DatabaseSchemaHook, so this PR's tests can run
before that PR merges. Must be removed before merging.
Every kernel extending IbexaTestKernel needs DoctrineSchemaBundle (for SchemaBuilderInterface)
and IbexaRepositoryInstallerBundle (for core's own BuildSchemaSubscriber) once DatabaseSchemaHook
builds the schema from the event, so registering them here rather than in each of the ~50
consuming packages keeps this from being a breaking change for all of them.

Both live in packages test-core already requires: doctrine-schema, and core itself, which is
where IbexaRepositoryInstallerBundle lives. They are registered as a pair because
IbexaRepositoryInstallerBundle::build() throws without DoctrineSchemaBundle.
Steveb-p added a commit to ibexa/user that referenced this pull request Sep 9, 2026
ibexa/test-core#43 rebuilds DatabaseSchemaHook on SchemaBuilderInterface::buildSchema()
instead of importing raw schema.yaml files, so the test kernel now has to register
DoctrineSchemaBundle (which provides SchemaBuilderInterface) and
IbexaRepositoryInstallerBundle (which holds core's own BuildSchemaSubscriber).
Steveb-p added a commit to ibexa/user that referenced this pull request Sep 9, 2026
Points CI at the branch that rebuilds DatabaseSchemaHook, so this PR's tests can run
before that PR merges. Must be removed before merging.
@konradoboza

Copy link
Copy Markdown
Contributor

@Steveb-p please create and attach a proper JIRA ticket.

@Steveb-p Steveb-p changed the title Rebuilt DatabaseSchemaHook on SchemaBuilderInterface instead of a raw-file reimplementation IBX-12530: Rebuilt DatabaseSchemaHook on SchemaBuilderInterface instead of a raw-file reimplementation Sep 9, 2026
@Steveb-p
Steveb-p merged commit ecb4cd1 into 4.6 Sep 10, 2026
7 checks passed
@Steveb-p
Steveb-p deleted the database-schema-hook-schema-builder branch September 10, 2026 12:06
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