AGENTS.md@packages/trueforge/src/db/postgres · git:20260831.2025cef · 2026-08-31 · sha256 cf71c032024e1a33
AGENTS.md@packages/trueforge/src/db/postgres git:20260831.2025cefA
Immutable. This exact content is served forever at /api/v1/blob/cf71c032024e1a33.
- Temporal columns MUST use `timestamptz` (`timestamp with time zone`). Do not use `timestamp` without time zone. - Application timestamps MUST be treated as UTC instants. Serialize with `Date.prototype.toISOString()` (always `...Z` with milliseconds). - Do not run DB queries inside loops (N+1). Prefer a single batched query, a join, or an `IN`/`ANY` lookup over per-item round-trips. - Postgres migrations MUST start `up`/`down` with `SET LOCAL lock_timeout = '5s'` so waiting DDL fails fast instead of blocking later queries (including `SELECT`s) behind it in the lock queue. - All app tables and Kysely migration bookkeeping live in the `trueforge` schema (not `public`). `runMigrations` bootstraps that schema (CREATE + move legacy `public` tables) before the Migrator runs; `createDb` sets `search_path=trueforge`.