Repository navigation
Conversation
getSchemaMetadata() appended per-table results with $metadata[], discarding which table each entry belonged to. Callers of getSchemaForeignKeys() received a flat list of ForeignKey[] groups with no way to map them back to their owning table. Also corrects @return annotations that documented ForeignKey[] and Index[] for values that have always been arrays of arrays, and loads fixtures in the schema tests, which previously passed vacuously against an empty database. BREAKING CHANGE: getSchemaChecks(), getSchemaDefaultValues(), getSchemaForeignKeys(), getSchemaIndexes(), getSchemaPrimaryKeys(), getSchemaUniques() and getTableSchemas() return arrays keyed by table name. Iterating with foreach is unaffected; code relying on sequential integer offsets must be updated. Closes yiisoft#1176
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1190 +/- ##
=========================================
Coverage 98.62% 98.62%
Complexity 1645 1645
=========================================
Files 120 120
Lines 4288 4288
=========================================
Hits 4229 4229
Misses 59 59 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes schema metadata aggregation so per-table schema results are returned keyed by table name (instead of a flat list that loses ownership information), addressing #1176 and making the affected APIs reliably mappable back to their tables.
Changes:
- Change
AbstractSchema::getSchemaMetadata()to index results by table name rather than appending to a numeric array. - Update PHPDoc / Psalm annotations for schema/constraint APIs to reflect the keyed-by-table return shape (including primary keys omitting tables without PKs).
- Update tests to expect keyed results and ensure fixtures are loaded so schema tests don’t pass against an empty database.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Db/Schema/SchemaTest.php | Updates unit-level schema tests to assert results are keyed by owning table name and FK metadata remains accessible. |
| tests/Common/CommonSchemaTest.php | Updates integration-style schema tests to load fixtures and iterate schema metadata as tableName => items. |
| src/Schema/SchemaInterface.php | Documents getTableSchemas() as returning an array indexed by table name (Psalm-typed). |
| src/Schema/AbstractSchema.php | Implements the core behavior change: schema metadata is aggregated as [$tableName => $tableMetadata]. |
| src/Constraint/ConstraintSchemaInterface.php | Corrects return annotations to reflect arrays-of-arrays keyed by table name (and PKs as array<string, Index>). |
| CHANGELOG.md | Adds a changelog entry documenting the behavioral change and affected methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace array<string, mixed> with the concrete union, matching the @return annotation directly above it. Refs yiisoft#1190
Tigrov
approved these changes
Aug 2, 2026
samdark
approved these changes
Aug 2, 2026
vjik
approved these changes
Aug 2, 2026
Member
|
Thanks 👍 |
This was referenced Aug 2, 2026
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.
getSchemaMetadata() appended per-table results with $metadata[], discarding which table each entry belonged to. Callers of getSchemaForeignKeys() received a flat list of ForeignKey[] groups with no way to map them back to their owning table.
Also corrects @return annotations that documented ForeignKey[] and Index[] for values that have always been arrays of arrays, and loads fixtures in the schema tests, which previously passed vacuously against an empty database.
BREAKING CHANGE: getSchemaChecks(), getSchemaDefaultValues(), getSchemaForeignKeys(), getSchemaIndexes(), getSchemaPrimaryKeys(), getSchemaUniques() and getTableSchemas() return arrays keyed by table name. Iterating with foreach is unaffected; code relying on sequential integer offsets must be updated.
Closes #1176