Validate and enforce the new customer relationship constraints
Application checks pass, but a direct import can still create a case with an absent new customer identity.
- Focused work estimate
- 3h 30m + prerequisites
- Priority in the scenario
- Medium
- Engineering practice
- Constraint validation · Migration operations
Estimated field mix
- Database engineering100%
Field percentages are editorial estimates of the ticket's engineering focus. They total 100%; they are not measured time, proficiency scores, or ownership evidence.
Review it, then add it to your workspace.
The board opens an editable draft; nothing is saved until you confirm it. Sign-in and workspace permissions apply, and Demo boards remain ephemeral.
Project context
A fictional support platform stores a mutable external account code as its primary relationship key. Renames and imports now break references in several tables.
Setup prerequisites
- Create a disposable database with synthetic customers and dependent records.
- Apply real migration files; never use production db push.
Preceding work
Complete these dependencies, or supply their agreed outputs before taking this ticket.
- AMIGRATE-101 · Inventory every reference to the mutable customer code
- AMIGRATE-102 · Add immutable customer IDs through an additive migration
- AMIGRATE-103 · Add nullable customer-ID references to dependent tables
- AMIGRATE-104 · Backfill customer IDs with resumable keyset batches
- AMIGRATE-105 · Bridge legacy customer writes to the new identity transactionally
- AMIGRATE-106 · Protect customer-code renames during the backfill window
- AMIGRATE-107 · Verify relationship completeness before making customer IDs mandatory
Acceptance criteria
- Add or validate foreign-key and non-null constraints after readiness.
- Document database lock expectations for each migration step.
- Reject writes violating the new relationship invariant.
Implementation constraints
- Use PostgreSQL-supported staged validation where appropriate; inspect actual SQL.
Verification to include
- Apply the constraint migration after a clean backfill.
- Attempt orphan and null references through direct SQL and observe rejection.
Deliverables
- Constraint migration and direct-write checks
Rollout and recovery
Apply in a controlled synthetic window; abort on lock contention and preserve the bridge schema.
Value of the work
For the engineer: Practice migration ordering, compatibility and referential integrity.
For the team: Review a reversible schema transition with measurable completeness checks.
Evidence boundaries
Outcome Evidence: Tests, patches, and runbooks are requested deliverables. They become Outcome Evidence only through a qualified Mission and immutable Evidence IDs.
Ownership Evidence: Independent adaptation must be observed under a declared verification policy and cite immutable Evidence IDs. Completing a planning ticket establishes no Ownership Evidence.