Migration Round Trip
Apply a database migration to a scratch database, roll it back, apply it again, and compare schemas until the migration is clean in both directions.
Copy the Migration Round Trip loop
Stops when up, down, and up again all succeed and the schema matches after each round trip, or after 6 iterations. Edit the settings block, then paste the whole prompt into your agent.
You are running the "Migration Round Trip" loop. Settings (edit before running): - Migration to test: <path to the new migration> - Scratch database URL: postgres://localhost:5432/migration_loop_scratch - Migrate up command: <for example, npx drizzle-kit migrate or alembic upgrade head> - Migrate down command: <for example, alembic downgrade -1> - Schema dump command: pg_dump --schema-only --no-owner - Max iterations: 6 Goal: the migration applies, rolls back, and re-applies cleanly, and the schema is identical at matching points. Each iteration: 1. Drop and recreate the scratch database. Migrate it to the version just before the migration under test. Seed a few representative rows in affected tables. 2. Dump the schema (snapshot A). Apply the migration. Dump the schema (snapshot B). 3. Run the down migration. Dump and diff against snapshot A. Any difference is a rollback bug. 4. Apply the migration again. Dump and diff against snapshot B. Any difference or error means the migration is not repeatable. 5. Check that the seeded rows survived in a sensible form. 6. Fix the migration and log what failed. Stop when: - All steps succeed and both diffs are empty. Success. - You reach the max iteration count. - The change cannot be reversed without data loss (for example dropping a column). Report it and suggest a safer pattern such as expand and contract. Rules: - Only connect to the scratch database URL above. Never run migrations against development, staging, or production databases. - Do not edit migrations that have already been applied elsewhere. Only the migration under test. - Avoid long table locks: flag any operation that rewrites a large table. Final report: final migration, the up and down diffs, data checks, and lock or data loss risks.
When this loop fits
- You wrote a migration and want proof that its rollback really restores the old schema.
- A migration failed halfway in staging and you need it to be safe to re-run.
- You review migrations from other people and want an automatic check before approving.
What happens on each pass
The agent repeats these steps until the stop condition holds or it runs out of iterations.
- Prepare a scratch database. Create a disposable database and migrate it to the state before the new migration.
- Snapshot and apply. Dump the schema, apply the migration, and dump the schema again.
- Roll back and compare. Run the down migration and diff the schema against the first snapshot.
- Apply again. Re-apply the migration and diff against the second snapshot.
- Fix and repeat. Fix the migration until every step succeeds and both diffs are empty.
MCP servers for this loop
The 6 strongest of 1347 matching servers, ranked by how closely they fit and then by trust score.
- 77Trust score 77 of 100, Good
Token-efficient database MCP server for PostgreSQL, MySQL, MariaDB, SQL Server, Oracle, SQLite
RegistryLicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 25 days ago. - 70Trust score 70 of 100, Good
Database MCP server for MySQL, MariaDB, PostgreSQL & SQLite with PII redaction and write-prevention
RegistryLicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 21 days ago. - 65Trust score 65 of 100, Good
ohmyho.st
by amerged-org · TypeScript
Operate ohmyho.st hosting from your coding agent: deploy GitHub apps, Postgres, mail, domains.
RegistryLicenseQualityMaintenanceLicense: A. Apache-2.0 is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 6 days ago. - 65Trust score 65 of 100, Good
pgmoat
by kitalon-labs-llc · TypeScript
Governed, read-only Postgres access for AI agents: SQL safety, RLS, budgets, tamper-evident audit.
RegistryLicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 7 days ago.
63Trust score 63 of 100, GoodDoxa MCP
by the-doxa-way · JavaScript
Record and hold prophetic encouragement for decades. Doxa's Bible (BSB) and encouragement tools.
RegistryRemoteLicenseQualityMaintenanceLicense: A. MIT is a permissive open source license.Quality: Not graded. No README or tool list has been captured yet.Maintenance: A. Last commit or release 12 days ago.
63Trust score 63 of 100, GoodMCP server for interacting with the Supabase platform
OfficialRegistryRemoteLicenseQualityMaintenanceLicense: Not graded. No license is recorded for this server.Quality: Not graded. No README or tool list has been captured yet.Maintenance: Not graded. No commit or release date has been recorded.
How to run this loop
- Connect the tools. Install a server the loop can use, for example DBHub, or rely on your agent's built-in terminal and file access.
- Edit the settings block. Replace the example commands, targets, and limits with your project's own. Keep the iteration cap low on the first run.
- Paste it into an agent session. Start a fresh session in Claude Code, Cursor, or VS Code agent mode, in the repository root, and paste the prompt.
- Review before you merge. Read the final report and the diff. The loop leaves its work for you to review rather than shipping it.
Migration Round Trip questions
When does the Migration Round Trip loop stop?
It stops as soon as up, down, and up again all succeed and the schema matches after each round trip. It also stops after 6 iterations by default, or earlier when the prompt's own stop rules say it is stuck, and then reports what changed and what is left. Change the cap in the settings block at the top of the prompt.
What if my migration tool does not support down migrations?
Skip the rollback steps and keep the repeatability check: apply the migration to a fresh copy twice in a row, from scratch each time, and compare schemas. It still catches non-deterministic migrations and partial failures.
Why does the loop insist on a scratch database?
The loop drops and recreates the database on every pass. That is exactly what you want for a reliable test and exactly what must never happen to a shared one. A disposable local or container database keeps the loop fast and harmless.