Database Migration Rollback & Data Integrity Test Plan
Validate database schema migrations for zero data loss, backward compatibility, and forward/backward rollbacks.
Interactive Prompt Playground
{{MIGRATION_SQL}}{{CURRENT_SCHEMA}}{{TABLE_VOLUME}}You are a Principal Database Administrator and Migration Testing Specialist. Review and test this database migration script for zero-downtime deployment safety: Migration SQL (Up & Down): ```sql -- V12__split_user_full_name.sql ALTER TABLE users ADD COLUMN first_name VARCHAR(100); ALTER TABLE users ADD COLUMN last_name VARCHAR(100); UPDATE users SET first_name = split_part(full_name, ' ', 1), last_name = split_part(full_name, ' ', 2); ALTER TABLE users DROP COLUMN full_name; ``` Current Production Schema: ```sql CREATE TABLE users ( id BIGSERIAL PRIMARY KEY, full_name VARCHAR(255) NOT NULL, email VARCHAR(255) UNIQUE NOT NULL, created_at TIMESTAMPTZ DEFAULT NOW() ); ``` Table Volume & Traffic: 8 million rows, 200 writes/second during business hours Analyze the migration against production safety standards: 1. **Locking & Table Rewrites**: - Will this migration acquire an `ACCESS EXCLUSIVE` lock that blocks reads/writes on high-traffic tables? - Does adding columns with default values trigger a full table rewrite? - Are indexes created using `CONCURRENTLY` (Postgres)? 2. **Backward Compatibility with Active App Version**: - Can the currently deployed version of the application run safely while this migration is applied (Expand/Contract Phase)? 3. **Data Integrity & Rollback Verification**: - If the rollback script executes, is there any permanent data loss for records created during the migration window? 4. **Automated Migration Test Script**: - Provide a test script (in SQL or Python/Testcontainers) that runs Up -> inserts dummy data -> runs Down -> asserts schema & data integrity.
How to Use This Prompt
- Paste your migration Up/Down scripts and current schema.
- Specify table volume and traffic.
- Get a safe, multi-phase zero-downtime migration plan with test validation.
Engineering Tips & Best Practices
- Never drop a column in the same release where you stop reading it. Always follow the two-release Expand/Contract lifecycle.
What This Prompt Inspects
Key failure modes, design principles, and quality standards evaluated during execution.
Expand/Contract Pattern
Prevents dropping columns immediately while old code replicas are still running.
Concurrent Index Creation
Verifies indexes are created with CREATE INDEX CONCURRENTLY.
Batch Updates
Batches massive backfill updates to avoid transaction log bloat.
SprintKit Workflow Integrations
Complementary interactive tools and workflows across SprintKit to accelerate your engineering process.
Related Prompts
Explore related developer prompts in this workflow domain.
Database Schema & Relational Indexing Strategy
Design production PostgreSQL schemas with composite indexes, foreign key strategies, and partitioning.
Database Deadlock & Concurrency Race Condition Investigator
Diagnose Postgres/MySQL transaction deadlocks, lock contention, and concurrent update race conditions.
Integration & Contract Test Plan (Testcontainers / Playwright)
Create robust integration test suites with real databases in Docker containers and contract verification.