Automate Database Migrations with AI
A comprehensive prompt to generate automated database migration scripts with rollback, validation, CI/CD integration and zero-downtime strategy.
Paste in your AI
Paste this prompt in ChatGPT, Claude or Gemini and customize the variables in brackets.
Tu es un ingénieur base de données senior spécialisé en automatisation des migrations. Tu maîtrises les outils de migration (Flyway, Liquibase, Alembic, Knex, Drizzle, Prisma) et les bonnes pratiques de gestion de schéma en production.
Contexte du projet :
- SGBD utilisé : [SGBD : ex. PostgreSQL, MySQL, SQLite, SQL Server]
- Outil de migration ou ORM : [OUTIL_MIGRATION : ex. Alembic, Drizzle, Prisma, Flyway, Knex, migration manuelle SQL]
- Langage backend : [LANGAGE : ex. Python, TypeScript, Java, Go]
- Description du changement de schéma souhaité : [DESCRIPTION_CHANGEMENT : ex. ajouter une colonne 'status' à la table 'orders', renommer une table, créer une relation many-to-many]
- Environnement cible : [ENVIRONNEMENT : ex. développement local, staging, production]
Génère une migration complète et automatisée en respectant ces exigences :
- Script de migration UP : le changement de schéma demandé, avec les types de données appropriés, les contraintes (NOT NULL, DEFAULT, INDEX) et les commentaires explicatifs.
- Script de migration DOWN (rollback) : l'opération inverse exacte pour revenir à l'état précédent, en gérant la perte de données potentielle.
- Script de migration de données (si applicable) : si le changement nécessite de transformer ou déplacer des données existantes, fournis le script de data migration séparé.
- Validation pré-migration : une requête SQL ou un script qui vérifie les prérequis avant d'exécuter la migration (existence de tables, absence de conflits).
- Validation post-migration : une requête ou un test qui confirme que la migration s'est bien appliquée.
- Script CI/CD : un extrait de pipeline (GitHub Actions, GitLab CI ou script bash) pour exécuter automatiquement les migrations lors du déploiement.
- Stratégie zero-downtime : si l'environnement est la production, propose une approche de migration sans interruption de service (expand-contract, blue-green, etc.).
Pour chaque élément, ajoute des commentaires expliquant le raisonnement et les risques potentiels. Signale explicitement toute opération destructive ou irréversible.
Personalize this prompt with Léa
Léa rewrites this prompt for your job and your exact goal — 3 quick questions.
Why this prompt works
<p>This prompt transforms the AI into a database engineer capable of producing complete, production-ready migrations. By specifying your <strong>DBMS</strong>, your <strong>migration tool</strong> and the <strong>change description</strong>, you get a deliverable directly integrable into your workflow.</p><p>The approach covers the entire migration lifecycle: the UP script to apply the change, the DOWN script to roll back, pre and post-execution validation, and integration into your CI/CD pipeline. This eliminates common oversights like missing rollback or lack of post-deployment tests.</p><p>For production environments, the prompt explicitly requests a <strong>zero-downtime strategy</strong>, which pushes the AI to propose patterns like expand-contract or multi-phase migrations. Adapt the variables to your stack: a Python/Alembic project will not have the same output as a TypeScript/Drizzle project, and that is precisely the point of customization.</p>
Use Cases
Expected Output
A complete set of migration scripts (UP, DOWN, data migration), pre and post-migration validation queries, a ready-to-use CI/CD pipeline excerpt, and a documented strategy for zero-downtime migrations.
Improve this prompt
Run this prompt through the Optimizer to strengthen its context, constraints and expected format.
Improve this prompt with the OptimizerComments
- LéaAI
Ajoutez une étape de linting SQL (ex: sqlfluff) dans votre pipeline CI/CD pour détecter erreurs syntaxiques et violations de conventions avant exécution. Cela évite des échecs coûteux en production.
📬 Get new prompts every week
Join our newsletter and never miss a prompt.
Go further
Similar Prompts
Build a webhook system
Build webhook infrastructure
Prompt Claude to Create a Prototype
Creating a prototype is a crucial step in developing a product, application, or service. Traditionally, this phase requires a variety of technical skills, time, and often a multidisciplinary team. With Claude, you can significantly accelerate this process by generating functional prototypes from a simple description of your idea. Whether you want to design an interactive user interface, a web application mockup, an API prototype, or even a technical proof of concept, Claude can produce functional code, HTML/CSS wireframes, or complete architectures ready to be tested. The major advantage is Claude's ability to iterate quickly: you describe your vision, get a first prototype, then refine through successive exchanges until you get exactly what you're looking for. This approach democratizes rapid prototyping and allows entrepreneurs, designers, and product managers to validate their hypotheses without fully relying on a development team in the early stages of the project.
Create Async Workers and Jobs with AI
A complete prompt to design and implement async workers and jobs with queuing, retry, monitoring and deployment.
GitHub Copilot Prompt for Generating JavaScript Code
GitHub Copilot, the AI-powered programming assistant developed by GitHub and OpenAI, has transformed the way developers write JavaScript code. By leveraging billions of lines of open-source code, Copilot can generate complete functions, classes, modules, and even entire architectures from simple natural language descriptions. To get the most out of this tool, mastering the art of prompt engineering for code generation is essential. A well-structured prompt produces clean, performant JavaScript code that adheres to modern best practices (ES2024+, implicit typing, error handling, modularity). In this guide, we offer optimized prompts for GitHub Copilot that will help you generate professional-grade JavaScript code, whether you're developing a REST API, a frontend component, a utility script, or complex business logic. Each prompt is designed to provide sufficient context to Copilot while allowing the flexibility needed for relevant and project-adapted generation.