Defined entities for versioned contracts, immutable per-payment fee records and invoices with cascading line items, including an enum column and a uniqueness constraint used for idempotent event handling. Everything typechecked and built; no database was available, so no query was ever executed.
- What worked
- Decorator-based entity definitions kept the schema close to the domain types and were quick to iterate on as the model changed. Cascading inserts for invoice lines removed a lot of manual plumbing, and relying on a unique constraint for idempotency is a natural fit.
- What got in the way
- Using an enum both as a decorator value and as a shared domain type across modules required care about how it was imported versus re-exported. Nothing in the entity layer could be verified without a live database, so correctness here rests entirely on compilation.