P
💻DeveloppementAdvancedAll AIs

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 :

  1. 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.
  2. 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.
  3. 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é.
  4. 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).
  5. Validation post-migration : une requête ou un test qui confirme que la migration s'est bien appliquée.
  6. Script CI/CD : un extrait de pipeline (GitHub Actions, GitLab CI ou script bash) pour exécuter automatiquement les migrations lors du déploiement.
  7. 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

Answer 3 questions and Léa tailors the prompt to your situation.

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

Generate a complete migration with rollback to add or modify columns in productionCreate a CI/CD pipeline that automatically executes and validates migrations on each deploymentPlan a zero-downtime migration to restructure a critical table without service interruption

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.

Learn more

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

View on Prompt Guide

Comments

Be the first to comment on this prompt.

📬 Get new prompts every week

Join our newsletter and never miss a prompt.

Similar Prompts

💻DeveloppementIntermediateChatGPT

Write Integration Tests for an API

Create complete API integration tests with database setup, authentication, CRUD, and end-to-end scenarios.

29243
💻DeveloppementAdvancedClaude

Set Up Application Observability

Implement the three pillars of observability (logs, metrics, traces) with OpenTelemetry, Prometheus, and Grafana dashboards.

44239
💻DeveloppementIntermediateAll AIs

DALL-E Prompt to Generate JavaScript Code

DALL-E, the image generation model developed by OpenAI, is not designed to produce executable JavaScript code. However, it can play a valuable complementary role in a JavaScript developer's workflow. DALL-E excels at creating visuals related to development: user interface mockups, architecture diagrams, data flow schemas, or illustrations to document your code. By crafting precise prompts, you can obtain visual representations of complex JavaScript concepts like closures, the event loop, or design patterns. These visuals then serve as references for implementing your code, creating attractive technical documentation, or designing educational materials. The approach is to use DALL-E as a rapid visual prototyping tool: generate a UI mockup, then translate it into JavaScript components. This method accelerates the design phase and reduces back-and-forth between designers and developers. In this guide, we offer optimized prompts to get the most out of DALL-E in your JavaScript development process, from UI prototyping to visual documentation of your code.

018
💻DeveloppementIntermediateAll AIs

Debug Your Python Code with ChatGPT

A structured prompt to get a complete analysis of your Python bugs: identification, root cause explanation, commented fix, and prevention tips.

0209