Skip to content

Act I — Blueprints & Guardrails#

Year 2 · Spring. Before knocking down a single wall, Maya checks what PostgreSQL actually built.

Year 2 · Spring. Before knocking down a single wall, Maya checks what PostgreSQL actually built.

Maya: Wait — how does pgdorm.migrate know what's in the database without scanning a folder of old SQL files?

Ferris: It queries PostgreSQL's own pg_catalog through typed read-only ORM models, diffs snapshots, and classifies every lock and hazard before a single byte of DDL crosses the wire.

Spring, Year 2. Three chapters that lay the foundation for zero-downtime schema evolution: building the schema step by step, introspecting pg_catalog, running declarative syncs with _pgdorm ledger tracking and three-way drift checks, and expanding dangerous DDL into PostgreSQL lock-safe online choreography (CONCURRENTLY, NOT VALID + VALIDATE, safe widenings, and view-dependency preflight guards).

Act I renovations#

Ch. Renovation What you'll get Superpowers
0 The Internship Build the Dormitory schema from its first table, one reviewed migration per step, with a diagram of where you are after each one. plan_migration() sync_schema() migration_history()
1 Opening the Blueprints Query pg_catalog with typed models, baseline an existing schema, sync declaratively, and catch out-of-band drift. baseline_schema() plan_migration() sync_schema()
2 Knocking Down Walls Safely Expand DDL into CONCURRENTLY and NOT VALID steps, block table rewrites and drops, and guard dependent views. LockMode HazardLevel UnsafeMigrationError