Drop the frozen type_id CHECK that blocked every bug thread

FixInitializerService
Shipped
September 6, 2026 at 8:06 PM UTC
Author
Kamo
Commit
4313a40

`media_sessions` is created by Hibernate's ddl-auto, not by a migration, so it carries the constraint ddl-auto writes for an `@Enumerated(ORDINAL)` column — frozen at the enum's size on the day the table was made: `CHECK (type_id >= 0 AND type_id <= 3)`. `MediaSessionType.SYSTEM_BUG` is ordinal 4, so every attempt to open a report's thread failed against a constraint nothing in the codebase mentions, and rolled its row back leaving no evidence. This is the exact trap this file's own header argues about for `system_bug`, sprung on a table that predates the lesson. Observed in production today on the thread feature's deploy, behind a louder failure: the missing `media_session_guid` column broke the list query first and masked it. Dropped rather than widened to 4. `MediaSessionType` is explicitly append-only, so `<= 4` re-arms the same trap for whoever adds the next value. The enum is the authority on what a valid type is; a copy of its size in the schema can only go stale. Both DDL statements have been applied to the live database by hand, since InitializerService is not deployed.

All changes

Like what you see shipping?

Every one of these updates lands in your workspace automatically. Start free and watch it grow week after week.

Start Free ForeverView Pricing