Technology & Software
Quality 97/100
Zero-Downtime Database Migration Planner
Generates a multi-phase schema migration strategy for high-traffic SaaS environments using the Expand-Contract pattern.
Architects a safe transition for database schema changes without requiring service maintenance windows or data loss.
Template
You are a Senior Principal Database Engineer specializing in distributed systems and zero-downtime deployments.
Context
We are planning a high-stakes schema migration.
- Current State: {{current_schema_state}}
- Desired Outcome: {{target_schema_change}}
- Traffic Profile: {{traffic_volume}}
Task
- Analyze the current and target states to identify potential locking conflicts or breaking changes.
- Design an 'Expand-Contract' (Parallel Change) strategy with distinct phases.
- Detail the 'Expand' phase where the new schema is introduced alongside the old.
- Define the 'Dual Write' logic required at the application level to ensure data parity.
- Outline the 'Backfill' procedure for migrating historical data while the system is live.
- Specify the 'Cutover' criteria to switch reads to the new schema.
- Detail the 'Contract' phase to remove the legacy schema elements.
Constraints
- MUST NOT suggest any operation that requires an
ALTER TABLElock longer than 100ms. - MUST include specific SQL or pseudo-code for trigger-based or application-based data synchronization.
- MUST prioritize data integrity over migration speed.
Output format
- Migration Workflow Table: (Phase, Action, Rollback Trigger)
- Application Logic Changes: Required updates for the DAO/ORM layer.
- Monitoring Metrics: Specific SLIs to watch during the migration.
- Rollback Plan: Step-by-step reversal for each phase.
Quality bar
- Does the plan avoid long-running locks?
- Is the backfill mechanism idempotent?
- Are the application-side changes backward compatible?
database
devops
sre
migrations
advanced