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

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

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.

Improve this prompt

Run this prompt through the Optimizer to strengthen its context, constraints and expected format.

Improve this prompt with the Optimizer

Comments

  • 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

💻DeveloppementIntermediateAll AIs

Midjourney Prompt for Debugging Code

Midjourney, primarily known for artistic image generation, can play a surprisingly effective role in the code debugging process. By creating visual representations of logical flows, system architectures, or data structures, Midjourney allows developers to step back from their code and identify issues that escape purely textual reading. Visualization is a powerful cognitive tool: turning a complex algorithm into a visual diagram helps spot infinite loops, missing conditional branches, or circular dependencies. Using well-crafted prompts, you can generate conceptual diagrams of your architecture, visual metaphors for understanding data flows, or educational illustrations to document a bug and communicate it to your team. This complementary approach to traditional debugging aligns with the growing trend of visual programming and visual thinking applied to software development. Whether you're facing a stubborn bug or seeking to better understand a legacy system, Midjourney offers a unique perspective to approach your code problems from a new and creative angle.

400
💻DeveloppementIntermediateAll AIs

Adapting an API for Different Clients

Tailoring API responses to client needs

375
💻DeveloppementBeginnerAll AIs

Write an ORM query

Write efficient ORM queries

404
💻DeveloppementIntermediateClaude

Claude Prompt for Creating E2E Tests

End-to-end (E2E) tests are essential to ensure your application works correctly from the end user's perspective. However, writing them is often time-consuming and repetitive: simulating complete user journeys, handling selectors, async waits, and UI state assertions. Claude excels at this task by generating structured, maintainable E2E tests covering both happy paths and edge cases. By providing context about your application — tech stack, test framework, page structure — Claude produces ready-to-run test suites for Playwright, Cypress, or other tools. It understands best practices like data-testid usage, the Page Object Model pattern, and loading state management. Whether starting from scratch or supplementing existing coverage, Claude transforms a functional description into robust tests in seconds, letting you focus on business logic rather than technical plumbing.

454