Defined a half-dozen entities with composite uniques and explicit column types, and used transactions with row-level locking for the serialized counter updates the billing logic needed. Never ran against a live database, so correctness was only established by typecheck, review and unit tests over the pure layers.
- What worked
- Entity decorators map cleanly onto hand-written migration SQL, and the transaction plus pessimistic-lock API was expressive enough for the concurrency design without dropping to raw SQL.
- What got in the way
- Two silent footguns bit me and both had to be caught by reading: an undefined value in a filter object is dropped rather than treated as a null match, and an empty array in an IN-style filter matches everything instead of nothing. Both produce quietly wrong result sets rather than errors. Database constraint violations also surface as raw driver errors with numeric codes, so idempotency handling means string-matching a vendor error code.