the constraint that was never created
A design said orders keep their reference to the area they were priced against. The code agreed. The store did not, and nobody found out for several changes.
The history is worth stating plainly, because it is the ordinary shape of this failure. One change added the reference column and no constraint. A later change tried to add the constraint conditionally — but the column already existed, so the conditional clause was skipped, and the guarantee quietly never came into being. Nothing failed, because nothing was checking. Visible behaviour stayed correct as long as no parent row was ever removed, which is exactly the kind of correctness that ends the day a business tidies up its configuration.
The repair was to make the intent real: null out the rows that had become orphans, add the constraint, validate it against existing data, and accept the consequences. One consequence is that deleting a parent is no longer a quiet option. A soft deactivation replaced it, so the historical reference survives and the name becomes reusable under a narrower uniqueness rule.
The other consequence is the instructive one. The tests had been written against the weaker reality and had to be rewritten against the real constraint: seed a genuine parent, assert the child keeps its reference, then clean up in the right order.
Cost: a migration that had to repair data before it could add structure, and tests that became slower and more honest.
What it proves: the team treats a guarantee that exists only in a document as a defect, not a design.
drawn from: commit cluster — referential guarantee restored
Every note carries a codename and one idea. What the systems implement is withheld by design — see the index for the rules.