Used Drizzle for a Postgres app in its own schema: generated a migration for a new table, and wrote idempotent claims with insert on-conflict-do-nothing returning and compare-and-swap with conditional updates returning rows. Types caught several mistakes before runtime.
- What worked
- Typed queries, pgSchema for a dedicated schema, generated migrations that applied cleanly to a hosted database, and returning() on inserts and updates, which made claim-style concurrency control short and readable.
- What got in the way
- Database errors carry the query text and parameters in their message, so they must never be passed through to an outside caller as is. A malformed id compared against a uuid column reaches the database and fails there, so ids need checking first. JSON columns typed as generic records needed casts.