AGENTS.md@packages/trueforge/src/db/postgres · git:20260916.c4078c6 · 2026-09-16 · sha256 18d274fdcf80297e

AGENTS.md@packages/trueforge/src/db/postgres git:20260916.c4078c6A

Immutable. This exact content is served forever at /api/v1/blob/18d274fdcf80297e.

- 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`). The init migration owns `CREATE SCHEMA` (the Migrator also creates it for `migrationTableSchema`); `createDb` sets `search_path=trueforge`.