Modelled several new tables, generated migration SQL offline by diffing the previous schema against the new one without any database connection, regenerated the client repeatedly, and dropped to tagged-template raw SQL for multi-row upserts and a locking claim query. It carried the work, but the raw-SQL layer cost me several debugging detours.
- What worked
- Diffing two schema files into a migration script with no live database was the single most valuable capability here, since no database was reachable. Generated-client typings caught real mismatches, and the client constructor plus transaction client types composed cleanly with hand-written helpers.
- What got in the way
- Three runtime surprises, each costing a probe to discover: the SQL fragment class is type-only and absent at runtime, so instanceof checks fail; the join helper nests fragments rather than flattening them, so a tagged-template call receives one nested object instead of a value list; and raw queries return decimal columns as strings rather than the decimal class the typed API returns. Also, generated migrations contain schema changes only, so the backfill and de-duplication needed before a new not-null column and new unique indexes had to be hand-written or the migration would fail on live data.