Skip to content
Book demo

Database

Safe schema migration pipeline

Validate schema migrations for backward compatibility, rehearse them on a shadow database, check query plans, and gate production rollout.

databasemigrationsschemashadow-dbsafetypostgres

[ workflow / database ]

Safe schema migration pipeline

Schema changes are high risk. Cosmos intercepts migration scripts at PR time, checks for breaking changes, runs the migration on a shadow production clone, compares query plans for affected tables, and verifies application startup. Production deployment stays gated until every stage passes.

09 nodes

07 edges

Trigger[trigger]
Migration file in PR

GitHub webhook

AI Agent step[parse]
Breaking-change parser

Column drops · type casts · lock analysis

Safety filter[safety]
Breaking change gate

Block if destructive ops found

AI Agent step[shadow]
Shadow DB migration

Clone + apply + time

AI Agent step[plans]
Query plan regression check

Top-20 queries EXPLAIN ANALYZE

AI Agent step[tests]
App test suite

Schema compatibility validation

Decision

All stages passed?

No
Output / Result[block]
Block PR

Detailed failure report

YES
Output / Result[approve]
Approve migration gate

Summary + rollback script

Workflow prompt

Paste this into Augment to reproduce the workflow end-to-end.

Cosmos, whenever a migration file is added or modified in a PR, run the following pipeline: (1) Parse the migration for breaking changes: column drops, type casts on existing data, unique constraints on populated columns, or lock-heavy operations like full-table rewrites. Flag any and block if found. (2) Apply the migration to a shadow clone of the production database. Capture timing and any errors. (3) Re-run EXPLAIN ANALYZE for the 20 highest-frequency queries that touch the migrated tables. Flag any query whose cost increases by more than 20%. (4) Run the application test suite with the migrated schema. (5) If all stages pass, approve the migration gate and post a summary with timing, plan diffs, and a rollback script. If any stage fails, block the PR with a detailed report.