feat: extend existing entity tables via #[Table(extends:)]#64
Merged
Conversation
Any module can now add columns to another module's entity table without touching the original entity class. Declare a plain Entity subclass with #[Table(extends: ParentEntity::class)] — the framework merges its columns/indexes/foreign-keys into the parent's table schema and hydrates the extender from the same row as a companion on the parent entity. Closes #63 Supersedes #59 Co-Authored-By: Claude Opus 4.7 (1M context) <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
#[Table(extends: ParentEntity::class)]on a plainEntitysubclass — its columns/indexes/foreign-keys merge into the parent's table schemaRepository::save()persists parent + companion data in a single INSERT/UPDATEEntityExtensionhierarchyHighlights
EntityAPIs:companions(),companion(class)(typed via@template),attachCompanion()SchemaRegistry::registerEntities()is two-pass: parses all, then merges each parent's table with linked extendersautoIncrementon extenders, duplicate column/index names (both class-strings in the error message)ENTITY_CLASSat construct; rejectsinsertBatch()when entities have companions attachedmigrate:diffsees the merged table — no extra code needed for schema migrationsTest plan
composer testsuite)Closes #63
🤖 Generated with Claude Code