Coding & Technical

Database Migration Plan and Script Generator AI Prompt

Database migrations are risky. You’re juggling schema changes, data transformations, downtime limits, and rollback safety. One missed dependency can break production. A vague prompt won’t cut it—you need a precise plan with commands, checks, and contingencies. A strong prompt tells the AI exactly what to generate and how to validate it.

This example shows how a well-structured prompt turns “help with migration” into a safe, staged migration plan with scripts, pre-flight checks, and rollback steps. AskSmarter.ai guides you with targeted questions about your database engines, version constraints, traffic windows, data volumes, and success metrics. You’ll get an actionable plan that fits your environment, not a generic checklist.

Use this template to reduce risk, shorten downtime, and improve confidence across teams during critical database changes.

The transformation

Before — Vague prompt

Help me migrate our database with minimal downtime.

After — Optimized prompt

You are a senior DevOps DBA. Create a production-safe migration from PostgreSQL 12 to 15.

  1. Context: 1 TB data, primary + 1 replica, app uses Sequelize ORM, read-only window 20 minutes.
  2. Deliverables: a) step-by-step migration plan b) pre-flight checklist c) cutover commands d) verification queries e) rollback plan.
  3. Constraints: zero data loss, keep replicas consistent, avoid long locks, use pglogical or pg_upgrade if justified.
  4. Include: exact psql/pg_dump/pg_restore commands, config changes, expected timings.
  5. Output format: numbered sections, code blocks for commands, risks with mitigations.

Why this works

The optimized prompt works because it provides clarity, context, and structure that direct the AI to produce actionable output.

  • Clarity: It defines the role (senior DevOps DBA) and the exact task (PostgreSQL 12 to 15). That sets expertise and narrows scope.
  • Context: It includes data size (1 TB), topology (primary + replica), ORM (Sequelize), and a 20-minute read-only window. These details drive realistic strategies and command choices.
  • Structure: It specifies deliverables (plan, checklist, commands, verification, rollback) and a required output format with numbered sections and code blocks. That yields a usable artifact, not prose.
  • Constraints and success criteria: It names zero data loss, replica consistency, minimal locks, and acceptable tools. The AI can weigh pglogical vs pg_upgrade with trade-offs.

AskSmarter.ai elicits these details through focused questions—engine versions, data volume, topology, downtime tolerance, tool preferences, and verification needs—so you get a safe, detailed plan on the first try instead of iterative guesswork.

When to use this prompt

  • Product Managers

    Define migration acceptance criteria and verification steps for a release that changes database versions or schemas.

  • Engineers

    Generate precise commands and scripts for a weekend cutover, including pre-flight checks and post-cutover tests.

  • DevOps Teams

    Plan blue-green or logical replication migrations that meet strict RTO/RPO targets with rollback paths.

  • Customer Success

    Prepare a clear communication plan on expected read-only windows and validation milestones for enterprise clients.

  • Researchers

    Compare migration strategies (in-place vs logical) with risks, timings, and tooling for a technical decision memo.

Pro tips

  • 1

    Quantify downtime and data volume to guide tool and strategy recommendations.

  • 2

    Specify topology (replicas, read replicas, failover) to ensure consistency steps are included.

  • 3

    Define verification queries and business KPIs so success checks match real user impact.

  • 4

    State rollback triggers and thresholds so the plan includes clear go/no-go decision points.

More coding & technical examples

Code Optimization Suggestions Report AI Prompt

Backend API Endpoint Design Specification AI Prompt

README Documentation Generator AI Prompt

Your turn

Build a prompt for your situation

This example shows the pattern. AskSmarter.ai guides you to create prompts tailored to your specific context, audience, and goals.