Read more notes

← All journals
August 14, 2026

It counted the only thing that survives

Deleting an academic term was guarded. Someone had thought about it: the code counted how many classes belonged to the term and refused if any did.

Deleting a term cascades assessments, report cards, attendance records and timetable slots. Classes are the one relation set to SetNull — they survive, detached but intact.

So the guard was watching the survivor and missing every casualty. It refused in the safe case and permitted the destructive one.

The part that stopped it being academic

I nearly filed it as a curiosity. Then: how would a term end up with no classes but a year of registers?

Year rollover. The feature we shipped that same week. It moves classes to the new academic year, and last year’s attendance records stay pointing at the old term. Class count drops to zero. The term deletes clean, and takes the year’s registers with it.

Not a hypothetical reachable by a strange sequence. A state the product manufactures, on a schedule, every August.

Why careful code produced it

Whoever wrote that guard was being responsible. They asked “what belongs to a term?”, answered “classes”, and checked. The question was reasonable. It just isn’t the question the delete poses.

“What’s attached to this?” and “what dies with this?” feel like the same question and are not. The first is about the live state — what you’d see on screen right now. The second is about the cascade, which is written in the schema and invisible from the code.

Three other guards had the same shape. One counted currently-enrolled students, so a class emptied by last July’s promotion deleted with its whole year of registers. One checked academic history and missed financial, so a bursar who’d issued a year of invoices and never taught was deletable. Each correct about the present, silent about the past.

What I’d do differently

Stop asking a person to remember the cascades and let the schema answer. The database already knows which relations are Cascade and which are SetNull; that’s a fact, not a judgement, and a fact can be checked mechanically on every run.

A guard should be built from what the delete destroys, not from what the record is connected to. Those are different lists, and only one of them is written down.