Governance Basics
8 examples to get you started with Postgres governance - 5 basic and 3 intermediate.
Prerequisites
ls docs/postgresql-style-guide.md # or repo equivalent
psql -c "SELECT extname FROM pg_extension ORDER BY 1;"- Executive sponsor for database standards (tech lead or head of platform).
- Database council or architecture review forum.
- CI hooks for migration filenames and SQL lint where possible.
Basic Examples
1. Schema Style Guide Scope
One document covers all product databases on Postgres.
# PostgreSQL Style Guide (excerpt)
- Tables: plural snake_case (`orders`, `line_items`)
- PK: `bigint GENERATED ALWAYS AS IDENTITY` or `uuid` with explicit default
- Timestamps: `timestamptz` named `created_at`, `updated_at`
- FK: `{referenced_table_singular}_id`
- No reserved words unquoted- Exceptions require ADR with expiry date.
- Style guide lives in git; PRs update it like code.
Related: Naming & Documentation Standards - comments and ERDs
2. Role Model
CREATE ROLE app_read NOLOGIN;
CREATE ROLE app_write NOLOGIN;
CREATE ROLE migrator LOGIN PASSWORD 'vault-rotated';
GRANT app_read TO app_api;
GRANT app_write TO app_worker;
-- migrator owns DDL in CI only- No shared
app_usersuperuser across services. BYPASSRLSreserved for break-glass accounts with audit.
3. Extension Allowlist
| Extension | Status | Owner |
|---|---|---|
| pgcrypto | Approved | platform |
| pgvector | Approved | search team |
| postgis | Approved | logistics |
| plpython3u | Denied | - |
SELECT extname, extversion FROM pg_extension;- New extension requests go through security review template.
Related: Extension & Plugin Governance - cadence
4. Migration Ownership
Service team authors SQL → DBA reviews tier → CI applies with migrator role- Flyway/Liquibase history table read-only to app roles.
- Production DDL never from laptop psql except break-glass with ticket.
5. ADR for Schema Exceptions
# ADR-0142: JSONB config blob on tenants
Status: Accepted
Context: Rapid tenant flags before GA
Consequence: Validate in app; migrate to columns by Q4
Review date: 2026-12-01- ADRs stored in
docs/adr/linked from ER diagrams.
Intermediate Examples
6. Production Schema Change Audit
-- Weekly job: objects created outside migrator role
SELECT obj.object_identity, ev.objid, ev.classid
FROM pg_event_trigger_ddl_commands() ev
JOIN pg_identify_object(ev.classid, ev.objid, ev.objsubid) obj
ON true;
-- Prefer ddl audit via pgaudit or event trigger in platform account- Alert if
CREATE TABLEowner is notmigrator.
7. Multi-Database Consistency
payments_db and billing_db both use same:
- naming guide
- timestamp conventions
- RLS policy naming (`{table}_tenant_isolation`)- Shared library for migration callbacks (
lock_timeout, etc.).
8. Governance Metrics
| KPI | Target |
|---|---|
| Migrations without tier tag | 0 |
| Unauthorized extensions | 0 |
| ADR exceptions past review date | 0 open |
| Council attendance | > 80% teams represented |
Related: Governance Best Practices - full checklist
Stack versions: This page was written for PostgreSQL 18.4 (stable 18, maintenance 17), pgvector 0.8+, PgBouncer 1.x, Patroni 3.x, and PostGIS 3.5+.