Skip to content

fix(database): use SchemaRegistry in DiffCommand and MigrateCommand for extender merge#67

Open
michalbiarda wants to merge 1 commit into
marko-php:developfrom
michalbiarda:fix/db-commands-extender-merge
Open

fix(database): use SchemaRegistry in DiffCommand and MigrateCommand for extender merge#67
michalbiarda wants to merge 1 commit into
marko-php:developfrom
michalbiarda:fix/db-commands-extender-merge

Conversation

@michalbiarda
Copy link
Copy Markdown

Summary

  • DiffCommand and MigrateCommand used a single-pass loop (metadataFactory->parse + schemaBuilder->build per entity) to build the entity schema, bypassing the two-pass extender merge in SchemaRegistry::registerEntities()
  • Replaced the loop with SchemaRegistry::registerEntities() in both commands
  • Removed the now-unused EntityMetadataFactory and SchemaBuilder constructor dependencies; updated test helpers accordingly

Closes #66

Steps to reproduce (before fix)

  1. Define a parent entity with #[Table(name: 'products')]
  2. Define an extender entity with #[Table(extends: Product::class)] that adds a column
  3. Run db:migrate — extender column is never added to the table
  4. If the column already exists in the DB, run db:diff — reports [DESTRUCTIVE] Drop column

Expected behavior

  • db:migrate generates and applies an ADD COLUMN migration for the extender column
  • db:diff reports no changes once the column exists in the database

Test plan

  • Run pest tests/Command/DiffCommandTest.php — all green
  • Run pest tests/Command/MigrateCommandTest.php — all green

🤖 Generated with Claude Code

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DiffCommand and MigrateCommand skip extender column merge

1 participant