fix(database): use SchemaRegistry in DiffCommand and MigrateCommand for extender merge#67
Open
michalbiarda wants to merge 1 commit into
Open
Conversation
…or extender merge Single-pass buildEntitySchema loop called schemaBuilder->build() per entity independently, so extender columns (Table(extends:)) were never merged into the parent table schema. Commands saw extender columns as missing from the entity definition — reporting existing ones as destructive drops and never generating ADD COLUMN for new ones. Replaced the loop with SchemaRegistry::registerEntities(), which already implements the correct two-pass merge. Removed the now-unused EntityMetadataFactory and SchemaBuilder constructor dependencies from both commands; updated test helpers accordingly. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
DiffCommandandMigrateCommandused a single-pass loop (metadataFactory->parse+schemaBuilder->buildper entity) to build the entity schema, bypassing the two-pass extender merge inSchemaRegistry::registerEntities()SchemaRegistry::registerEntities()in both commandsEntityMetadataFactoryandSchemaBuilderconstructor dependencies; updated test helpers accordinglyCloses #66
Steps to reproduce (before fix)
#[Table(name: 'products')]#[Table(extends: Product::class)]that adds a columndb:migrate— extender column is never added to the tabledb:diff— reports[DESTRUCTIVE] Drop columnExpected behavior
db:migrategenerates and applies anADD COLUMNmigration for the extender columndb:diffreports no changes once the column exists in the databaseTest plan
pest tests/Command/DiffCommandTest.php— all greenpest tests/Command/MigrateCommandTest.php— all green🤖 Generated with Claude Code