Skip to content

Commit 09c1b21

Browse files
committed
Maintainability pass from PR review
Four targeted fixes from a code review pass on the schema-reconciliation code, picked for clear correctness or future-debug-cost improvements: 1. META_DATABASES / META_ATTRIBUTES / META_INDEXES class constants. ~30 bare collection-name string literals are now phpstan-checkable and a typo no longer compiles. Avoided false-positive replacements in getAttribute('attributes', []) / collectionStructure['indexes'] etc., which name UtopiaDocument fields, not collections. 2. resetRunState() called at top of run(). $rowBuffer, $orphansByTable, and $processedTwoWayPairs are instance state that previously leaked across run() invocations on a reused Appwrite destination instance. A second run on the same instance would inherit the first run's processed-pair set and silently SKIP unrelated two-way attributes. 3. tolerateMissing() renamed to bestEffort(). The previous name implied it caught only NotFound errors, but the implementation swallows all \Throwable. Honest naming prevents 'why didn't the orphan get cleaned up' debugging time later. 4. Inconsistent partner-side error message: 'Column limit exceeded' on line 949 was a copy-paste drift from the parent block's correct 'Attribute limit exceeded'. Same conceptual failure should surface the same user-visible message. 5. TwoWayPartner value object + resolveTwoWayPartner() helper. Three sites (dropAttributeForRecreate, refreshTwoWayPartnerOnDelete, dropOrphanAttribute) independently extracted relatedCollection / twoWayKey from options with subtly different fallback handling (?? null vs ?? ''). Single helper returns ?TwoWayPartner with relatedTable / partnerKey / partnerMetaId; null when not two-way or the partner table has gone away. Inconsistent fallbacks were a P1 bug waiting to ship. All four are P1 reviewer concerns. Larger items (split createField, template-method for the pre-check skeleton) deferred to a follow-up PR per the user's explicit instruction. 31/31 unit tests pass, pint clean, phpstan level 3 clean.
1 parent c13e77d commit 09c1b21

2 files changed

Lines changed: 110 additions & 71 deletions

File tree

0 commit comments

Comments
 (0)