Simplify a crowded schema
Inventories unused Postgres views, triggers, functions, and duplicate tables, untangles confusing names, and verifies safe rollout before retiring anything.
Simplify a crowded schema. Retire unused PostgreSQL objects and duplicate storage without breaking live readers. Run these steps one at a time. Wait for my yes after each step. Stay read-only during Steps 1–3. Any migration replay runs only on a separate database with safe test data, never on production. Step 1 (inventory objects & consumers — read-only): List tables, views, materialized views, triggers, functions, and indexes that look obsolete or redundant, verifying real consumers including dynamic queries and external readers. Bring back: dependency map, ranked removal candidates, and migration risk. Stop if the schema is small and every object has a known reader. Step 2 (duplicate facts & naming — read-only, if needed): Check for facts maintained in multiple tables/views that can drift apart, and misleading table or column names causing real bugs or agent errors (skip cosmetic renames). Bring back: authoritative vs. duplicate stores and low-risk boundary fixes. Step 3 (pre-merge safety check — read-only / test copy): Before removing or changing any object, verify existing records stay intact, running app versions survive rollout, locks are safe, and a real rollback exists. Replay the migration on a separate test database. Step 4 (apply approved removals): After I approve, ship the smallest safe cleanup and confirm unchanged outputs for users and queries. Start your report in plain English: what you found, what it means, and whether I need to do anything. Put files, lines and commands underneath.
Simplify a crowded schemaAs one prompt
Steps
- 1Inventory unused database objectsmap tables, views, triggers, functions, and real callers (read-only)
- 2Check duplicated facts & confusing namesfind drifting copies and misleading names (read-only)
- 3Check deploy safety before mergingverify old and new app versions coexist and test migrations on a separate database
- 4Retire confirmed dead objectsremove complexity with unchanged results for users
- Use it when
- Your Postgres schema has accumulated old views, triggers, and redundant tables nobody dares to delete.