Defect Scenarios Best Practices
Post-mortem schema changes into lint rules. Every modeling defect that became an incident should leave a CI check or review gate behind.
Search across all documentation pages
Post-mortem schema changes into lint rules. Every modeling defect that became an incident should leave a CI check or review gate behind.
*_id referencing another table. Waivers need ADR comment in migration.tag1, tag2 columns.timestamptz for absolute instants. Ban new timestamp without time zone for user events in linter.text + CHECK over ENUM for evolving states. Enum only with closed set ADR.ADD VALUE on enums. Flag for DBA review and load test requirement.EXPLAIN regression for top 10 reporting queries. Row count explosion fails CI.timestamp vs timestamptz and enum.Orphan detection via LEFT JOIN ... WHERE parent IS NULL for every FK pair - catches missing FK and app bugs early.
Use sqlfluff, squawk, or custom scripts parsing CREATE TABLE for _id without REFERENCES.
Yes - nightly read-only queries with alerts. Cheaper than finance reconciliation incidents.
Order by incident frequency and severity: cross-tenant leak, fan-out revenue, orphans, timezone, enum lock.
Waivers with expiry for prototypes. Production paths have no waiver without VP sign-off.
Rule description, sample failing SQL, sample passing SQL, owner, link to incident ID, CI job name.
CI sets TimeZone to America/New_York and UTC; assert same timestamptz row orders consistently.
Yes - generate migrations from ORM still subject to SQL lint on output files.
They use multi-table fixtures with known cardinalities - integration level, not mocked repositories.
Never on production revenue and auth paths. Internal admin tools still need tenant isolation checks if multi-tenant.
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+.
Reviewed by Chris St. John·Last updated Jul 19, 2026