P
AdvancedClaude

Plan a Zero-Downtime Database Migration

Plans a production database migration with zero downtime using the expand-contract pattern, with exact SQL, checks, rollback and monitoring.

Paste in your AI

Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.

Tu es un expert en migrations de bases de données en production. Aide-moi à planifier une migration sans interruption de service.

**SGBD :** [SGBD] (ex: PostgreSQL 15)
**Taille de la table concernée :** [TAILLE_TABLE]
**Trafic en production :** [TRAFIC] (ex: 500 req/s, fenêtre de maintenance possible à 3h UTC)
**Migration à effectuer :** [DESCRIPTION_MIGRATION] (ex: ajout d'une colonne NOT NULL, renommage de table)

**Schéma actuel :**
```sql
[SCHEMA_ACTUEL]
```

Planifie la migration selon le pattern expand-contract :
1. **Phase Expand** : changements rétrocompatibles (scripts SQL)
2. **Phase Migration du code** : déploiement de l'application
3. **Phase Contract** : nettoyage des anciens éléments

Pour chaque phase :
- SQL exact à exécuter
- Vérifications avant/après
- Durée estimée et impact performance
- Procédure de rollback

4. **Monitoring** : métriques à surveiller pendant la migration
5. **Plan de rollback complet** si la migration échoue
6. **Checklist** pré et post-migration

Why this prompt works

The expand-contract pattern is the most proven technique for zero-downtime migrations but poorly documented. Requesting rollback for each phase reflects the rigor needed in production. Estimated duration per phase allows planning the migration during low-traffic windows.

Use Cases

Renaming a column in productionAdding a NOT NULL constraint on a large tablePartitioning a rapidly growing table

Expected Output

A 3-phase plan (expand/migration/contract) with exact SQL, checks, estimated duration, per-phase rollback, monitoring metrics and complete checklist.

Learn more

Check the full skill on Prompt Guide to master this technique from A to Z.

View on Prompt Guide

📬 Get new prompts every week

Join our newsletter and never miss a prompt.