name: postgres-schema-design description: Design PostgreSQL names, relations, history, work queues, and cursors. metadata: version: "1.0.1"
PostgreSQL schema design
Read applicable AGENTS.md and the repository's local database adapter when present. Local policy overrides these portable conventions.
- Names explain the stored thing; read naming when naming schema objects.
- Columns say their type and FK target; finite sets use enums or lookup tables.
- Joined identities use foreign keys; read relations before modeling references.
- Split differing shapes, share identical values, and keep history documents as JSON.
- Use canonical table shapes for revisions, changes, work, and cursors.
- Default to finite retention for everything except user content; see table shapes.
- Reuse parameterized trigger functions instead of copying bodies.
- Comment every table, column, and view; document reviewed exceptions explicitly.
For query shape, read performance patterns. For partition lifecycle, use UUIDv7 partitioning. For how jobs choose, cap, and resume over work-item and cursor tables, read bounded iteration. Consumer policy owns lifecycle, retention, migration strategy, and enforcement configuration.