Inferensys

Prompt

Schema Migration Plan Generation Prompt

A practical prompt playbook for generating structured, step-by-step migration plans for breaking API schema changes. Designed for backend engineers and API platform teams who need ordered rollout steps, consumer impact coverage, and rollback safety.
Operations team reviewing AI vendor onboarding platform on laptop, forms and contracts visible, casual office workspace.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise conditions, required inputs, and anti-patterns for using the Schema Migration Plan Generation Prompt.

This prompt is designed for backend engineers and API platform teams who have a concrete, breaking schema change to roll out and need a structured, step-by-step migration plan. The ideal user has already completed the schema design, understands the specific differences between the old and new contracts (a schema diff), and has a known inventory of internal and external consumers. The core job-to-be-done is translating a technical breaking change into a safe, sequenced operational plan that minimizes consumer downtime and provides clear rollback checkpoints.

Before using this prompt, you must assemble three critical inputs: a concrete schema diff (e.g., an OpenAPI or GraphQL diff), a list of known consumers and their current usage patterns, and a target deprecation timeline. The prompt uses these to generate a plan that includes dual-write periods, deprecation windows, and explicit rollback steps. It will also validate that migration steps are ordered correctly—for example, ensuring a dual-write phase begins before any old field is deprecated—and that no consumer in your provided inventory is left without a migration path. The output is a structured plan meant for human review and adaptation, not an auto-executed script.

Do not use this prompt for non-breaking changes, greenfield API design, or when your consumer inventory is unknown or incomplete. If you are simply adding a new optional field, a full migration plan is unnecessary overhead. Similarly, if you cannot enumerate your consumers, the prompt cannot validate that no one is stranded, making the output dangerously incomplete. The generated plan is a starting point for your runbook; it requires an engineer to verify sequencing, adjust timelines, and add operational details like monitoring dashboards and communication templates before execution.

PRACTICAL GUARDRAILS

Use Case Fit

Where this prompt works, where it fails, and what you must provide to get a reliable migration plan.

01

Good Fit: Multi-Step Breaking Changes

Use when: you have a concrete breaking change (field removal, type change) that requires a phased rollout across multiple services. Why it works: the prompt structures the plan around dual-write periods, deprecation windows, and rollback checkpoints that prevent stranded consumers.

02

Bad Fit: Greenfield Schema Design

Avoid when: you are designing a new API from scratch with no existing consumers. Risk: the prompt assumes an existing production surface and will hallucinate migration steps for non-existent dependencies. Use a design review prompt instead.

03

Required Input: Consumer Dependency Map

What to watch: without a list of known consumers and their read/write patterns, the plan will be generic and miss critical migration ordering. Guardrail: always provide [CONSUMER_DEPENDENCIES] with client names, read fields, and write fields before generating the plan.

04

Operational Risk: Dual-Write Drift

What to watch: the prompt may generate a dual-write period without specifying reconciliation checks. Guardrail: add a [RECONCILIATION_RULES] input requiring daily drift detection queries and alert thresholds before the old field is removed.

05

Operational Risk: Rollback Blindness

What to watch: plans often list rollback as a single step without per-phase criteria. Guardrail: require the output to include a rollback readiness check at each phase boundary with specific metrics (error rate, consumer traffic, data integrity) that must pass before proceeding.

06

Bad Fit: Single-Service Internal Refactor

Avoid when: the change is internal to one service with no external API surface change. Risk: the prompt over-engineers a migration plan with consumer coordination steps that don't apply. Use a simpler database migration or code refactor prompt instead.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt for generating a step-by-step schema migration plan with dual-write periods, deprecation windows, and rollback checkpoints.

This prompt template is designed to produce a structured, actionable migration plan when you need to roll out a breaking change to a database schema, API contract, or data model. It forces the model to reason about ordering, consumer impact, and safety checkpoints rather than generating a generic list of steps. Before using it, you must gather the current and target schemas, a list of known consumers, and any operational constraints like maintenance windows or data volume thresholds.

text
You are a senior infrastructure engineer planning a safe, phased schema migration. Your goal is to produce a step-by-step migration plan that minimizes risk to downstream consumers and allows rollback at any stage.

## INPUTS
- Current Schema: [CURRENT_SCHEMA]
- Target Schema: [TARGET_SCHEMA]
- Known Consumers: [CONSUMERS]
- Operational Constraints: [CONSTRAINTS]
- Risk Tolerance: [RISK_LEVEL]

## OUTPUT SCHEMA
Return a JSON object with the following structure:
{
  "migration_name": "string",
  "summary": "string (one-paragraph overview of the change and its impact)",
  "breaking_changes": [
    {
      "change": "string (description of what is breaking)",
      "affected_consumers": ["string"],
      "severity": "CRITICAL | HIGH | MEDIUM | LOW"
    }
  ],
  "phases": [
    {
      "phase_number": "integer",
      "name": "string",
      "objective": "string",
      "steps": [
        {
          "step_number": "integer",
          "action": "string (precise, executable instruction)",
          "owner": "string (team or role)",
          "verification": "string (how to confirm the step succeeded)",
          "rollback_action": "string (how to undo this step if verification fails)",
          "consumer_impact": "NONE | READ_ONLY | DOWNTIME | DEGRADED"
        }
      ],
      "gate_criteria": "string (conditions that must be met before proceeding to the next phase)"
    }
  ],
  "dual_write_periods": [
    {
      "description": "string",
      "start_phase": "integer",
      "end_phase": "integer",
      "affected_fields": ["string"]
    }
  ],
  "deprecation_windows": [
    {
      "field_or_endpoint": "string",
      "announcement_phase": "integer",
      "removal_phase": "integer",
      "consumer_migration_guide": "string"
    }
  ],
  "rollback_checkpoints": [
    {
      "after_phase": "integer",
      "rollback_plan": "string (concise plan to return to the previous state)",
      "data_integrity_risk": "string"
    }
  ],
  "stranded_consumers": [
    {
      "consumer": "string",
      "reason": "string (why this consumer cannot migrate without changes)",
      "recommended_action": "string"
    }
  ]
}

## CONSTRAINTS
1. Every phase must have a verification step and a rollback action.
2. No phase should strand a consumer without documenting it in `stranded_consumers`.
3. Dual-write periods must precede any removal of old fields or endpoints.
4. Deprecation windows must include a consumer migration guide.
5. Steps must be ordered so that no irreversible action occurs before its rollback checkpoint is defined.
6. If a consumer cannot be migrated, flag it in `stranded_consumers` and do not proceed with a plan that silently breaks it.
7. If the risk level is HIGH or CRITICAL, include a manual approval gate before any irreversible step.

To adapt this template, replace each square-bracket placeholder with concrete data. [CURRENT_SCHEMA] and [TARGET_SCHEMA] should be the full schema definitions in a machine-readable format like SQL DDL, OpenAPI YAML, or protobuf. [CONSUMERS] should list every known service, client, or team that reads from the schema, including internal and external dependencies. [CONSTRAINTS] should capture maintenance windows, data volume limits, compliance requirements, and team availability. [RISK_LEVEL] accepts LOW, MEDIUM, HIGH, or CRITICAL and controls the strictness of gating and rollback requirements. After generating the plan, validate that all phases are ordered correctly, no consumer is missing from the impact analysis, and every irreversible step has a preceding rollback checkpoint. For high-risk migrations, route the output through a human review step before any phase begins execution.

IMPLEMENTATION TABLE

Prompt Variables

Replace each placeholder with concrete data before executing the Schema Migration Plan Generation Prompt. Incomplete or inaccurate inputs produce plans that strand consumers or miss rollback windows.

PlaceholderPurposeExampleValidation Notes

[SOURCE_SCHEMA]

The current API schema version before migration. Must be a valid OpenAPI, GraphQL, or gRPC schema document.

openapi: 3.0.3 info: version: 2.4.1

Parse check: valid spec format. Must match the schema type declared in [SCHEMA_FORMAT]. Null not allowed.

[TARGET_SCHEMA]

The desired API schema version after migration. Must contain all breaking changes to be planned.

openapi: 3.0.3 info: version: 3.0.0

Parse check: valid spec format. Diff against [SOURCE_SCHEMA] must produce non-empty breaking change set. Null not allowed.

[SCHEMA_FORMAT]

The schema specification format. Controls which compatibility rules and diff tools apply.

openapi

Enum check: must be one of openapi, graphql, grpc, or avro. Mismatch with actual schema content causes invalid plans.

[CONSUMER_REGISTRY]

List of known API consumers, their contact channels, and their current schema version in use. Drives consumer impact and notification sequencing.

Schema check: each entry must have name, contact, and current_version fields. Empty list allowed if no consumers are known, but plan must flag this as high risk.

[DEPLOYMENT_ENVIRONMENTS]

Ordered list of environments where the migration will be executed. Determines rollout sequencing and rollback checkpoints.

["dev","staging","production-us","production-eu"]

Order check: must be non-empty and ordered from lowest to highest risk. Production environments must appear last.

[ORGANIZATIONAL_CONSTRAINTS]

Business rules that constrain the migration timeline. Includes blackout windows, SLA commitments, and regulatory freeze periods.

{"blackout_windows":["2025-11-20 to 2025-12-05"],"min_deprecation_days":30,"max_parallel_migrations":1}

Schema check: must include min_deprecation_days as positive integer. blackout_windows must be valid date ranges. Null allowed if no constraints exist, but plan must note absence.

[ROLLBACK_POLICY]

Defines acceptable rollback strategies and maximum tolerable downtime per environment. Shapes rollback checkpoint design.

{"strategy":"traffic-shift","max_downtime_seconds":60,"require_automated_rollback":true}

Schema check: strategy must be one of traffic-shift, redeploy-previous, or feature-flag. max_downtime_seconds must be non-negative integer. Null not allowed.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the schema migration plan prompt into a CI/CD pipeline or API governance workflow with validation, retries, and human review gates.

This prompt is designed to be called programmatically as part of an API change management pipeline, not as a one-off chat interaction. The typical integration point is a CI check that triggers when a pull request modifies an OpenAPI, GraphQL, or protobuf schema file. The harness should extract the schema diff, assemble the required inputs (current schema, proposed schema, consumer registry, deployment topology), and invoke the model with the prompt template. Because migration plans carry operational risk, the harness must treat the model output as a draft requiring structured validation before it reaches a human reviewer or an automated rollout system.

Start by building a thin orchestration layer that: (1) detects schema changes in version control, (2) fetches the current and proposed schema artifacts, (3) queries your API consumer registry for affected clients, and (4) populates the prompt's [CURRENT_SCHEMA], [PROPOSED_SCHEMA], [CONSUMER_LIST], and [DEPLOYMENT_CONTEXT] placeholders. The model should be called with temperature=0.2 or lower to reduce variance in plan structure. Parse the output against a strict JSON schema that validates required fields: migration_steps (ordered array), dual_write_period_days, deprecation_window_days, rollback_checkpoints (array), and stranded_consumers (array). Reject and retry any response that fails schema validation, up to three attempts, with the validation error message appended to the retry prompt as [PREVIOUS_ERROR]. Log every attempt and the final validated output for auditability.

After validation, the harness should run automated sanity checks before surfacing the plan for human review. Verify that migration steps are topologically ordered (no step references a later step's artifact), that every consumer in the input list appears in either the migration path or the stranded-consumers list, and that rollback checkpoints correspond to reversible steps. Flag any plan that recommends a dual-write period shorter than your organization's minimum (commonly 7 days) or a deprecation window shorter than your API versioning policy allows. These checks prevent the model from producing a plan that is syntactically valid but operationally dangerous. The harness should attach these automated findings as annotations on the pull request, alongside the full migration plan, so the reviewing API platform engineer can see both the plan and the harness's concerns in one view.

Human review remains mandatory for any migration plan that includes breaking changes, affects consumers outside your team's ownership, or modifies authentication or authorization scopes. The harness should enforce this by checking the [RISK_LEVEL] input and the presence of breaking changes in the diff. If the risk level is high or the diff contains breaking changes, the pipeline must block merge until an authorized reviewer from the API platform team approves the plan. Store the approved plan as an artifact in your API registry or developer portal so consumers can discover it. For lower-risk changes, the harness can auto-approve the plan if all automated checks pass and the plan contains no stranded consumers. Avoid wiring this prompt directly to an automated rollout system without a human-in-the-loop step for any change that modifies the wire format or removes fields.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape of the model response for a migration plan. Use these fields to build a JSON schema validator or a structured output parser in your application harness.

Field or ElementType or FormatRequiredValidation Rule

migration_plan_id

string (slug)

Must match pattern migration-[a-z0-9-]+. Parse check.

plan_title

string

Length between 10 and 120 characters. Not null or empty.

breaking_change_summary

string

Must reference at least one specific field or endpoint from [SCHEMA_DIFF]. Citation check required.

consumer_impact_assessment

object

Must contain affected_consumers (array of strings) and severity (enum: breaking, dangerous, safe). Schema check.

migration_phases

array of objects

Minimum 1 phase. Each phase object must include phase_number (integer), name (string), duration_estimate (string), and steps (array of strings). Schema check.

dual_write_period

object

If present, must include start_condition (string), end_condition (string), and fields_in_scope (array of strings). Null allowed if no dual-write needed.

deprecation_window

object

Must include deprecated_field_or_endpoint (string), announcement_date (ISO 8601), removal_date (ISO 8601), and replacement_guidance (string). Schema check.

rollback_checkpoints

array of objects

Minimum 1 checkpoint. Each object must include checkpoint_name (string), trigger_condition (string), and rollback_steps (array of strings). Schema check.

PRACTICAL GUARDRAILS

Common Failure Modes

What breaks first when generating schema migration plans and how to guard against it.

01

Hallucinated Migration Steps

Risk: The model invents migration commands, tool names, or framework-specific syntax that do not exist in the target stack. Guardrail: Require the prompt to reference a provided [MIGRATION_TOOLSET] list and validate generated commands against that list before accepting the plan.

02

Incorrect Step Ordering

Risk: The plan places a destructive action (e.g., column drop) before a safe action (e.g., dual-write activation), causing data loss or downtime. Guardrail: Add a post-generation validation step that checks for topological ordering: all writes must precede reads, and all reads must precede deletes.

03

Missing Consumer Impact Windows

Risk: The plan omits deprecation windows or assumes all consumers migrate instantly, stranding downstream services. Guardrail: Require the output to include explicit [DEPRECATION_WINDOW_DAYS] and [CONSUMER_LIST] fields, and flag any plan that lacks a parallel-run period for breaking changes.

04

Vague Rollback Instructions

Risk: The plan says 'roll back if needed' without specifying exact commands, data state checks, or rollback order, making recovery impossible under pressure. Guardrail: Enforce a required [ROLLBACK_PLAN] section with step-by-step reversal commands and a pre-rollback data integrity check query.

05

Schema Drift Between Environments

Risk: The plan assumes dev, staging, and production schemas are identical, ignoring environment-specific indexes, constraints, or data volumes that cause migration failure. Guardrail: Require [ENVIRONMENT_SCHEMAS] as input and validate that each migration step is tested against all environment definitions before finalizing the plan.

06

Unbounded Migration Scope

Risk: The model expands the migration to include unrelated refactoring or 'while-you're-at-it' changes that introduce new risks. Guardrail: Constrain the prompt with a strict [CHANGE_SCOPE] boundary and add a post-generation diff check that rejects any step touching tables or fields outside the declared scope.

IMPLEMENTATION TABLE

Evaluation Rubric

Score each criterion on a pass/fail basis. A migration plan must pass all criteria to be accepted before shipping.

CriterionPass StandardFailure SignalTest Method

Step Ordering Correctness

All steps are ordered by dependency: dual-write precedes cutover, deprecation precedes removal, rollback checkpoints follow each irreversible action

A step references a resource or state not yet created by a prior step; rollback checkpoint appears after the action it should gate

Topological sort of step dependency graph; verify no forward references to unestablished state

Consumer Coverage Completeness

Every known consumer of the affected schema is listed with a migration status (blocked, ready, migrated, unaffected)

A consumer present in [CONSUMER_REGISTRY] is missing from the plan; a consumer is marked unaffected but calls the deprecated field

Cross-reference plan consumer list against [CONSUMER_REGISTRY]; spot-check 3 consumers for correct status assignment

Dual-Write Period Specification

Dual-write start and end conditions are explicit: trigger event, duration, success metric, and rollback gate

Dual-write period has no end condition; success metric is undefined; rollback gate is missing or references a future step

Parse plan for start condition, end condition, metric, and rollback gate fields; confirm all four are non-null and concrete

Deprecation Window Definition

Deprecation window includes start date, end date, consumer communication template, and sunset header enforcement date

Deprecation window lacks a communication template; sunset header date is after the removal date; window duration is zero or negative

Validate date ordering: deprecation start < sunset header < removal; check communication template is non-empty and references [FIELD_NAME]

Rollback Checkpoint Placement

A rollback checkpoint with explicit revert steps and data reconciliation procedure follows each migration phase boundary

A phase boundary (dual-write start, cutover, removal) has no associated rollback checkpoint; revert steps reference dropped columns or removed endpoints

Count phase boundaries in plan; verify matching rollback checkpoint count; confirm each revert step is reversible given the state at that phase

Breaking Change Justification

Each breaking change includes a rationale, consumer impact summary, and alternative considered with reason for rejection

A breaking change is listed with no rationale; impact summary says none when consumers are affected; no alternative is documented

For each breaking change in [DIFF_REPORT], assert rationale field is non-empty, impact summary lists affected consumers, and alternatives field is populated

Migration Validation Script Coverage

Plan includes or references a validation script that checks: schema compatibility, data integrity, consumer connectivity, and rollback readiness at each phase

Validation script is missing; script checks only schema but not data integrity; script cannot run at a specific phase boundary

Execute validation script reference against a test environment at each phase; confirm exit code 0 for pass, non-zero for fail with actionable output

Timeline Realism Check

All durations account for consumer update cycles, QA windows, and business calendar constraints; no step is scheduled during a known freeze window

A step duration is shorter than the documented consumer update SLA; a cutover is scheduled during [FREEZE_WINDOW]; timeline has overlapping phases

Compare each step duration against [CONSUMER_SLA] minimum; cross-reference dates against [FREEZE_CALENDAR]; verify no phase overlap in timeline

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Use the base prompt with a single migration scenario and lighter validation. Remove strict ordering checks and rollback verification. Accept a free-text plan as long as it covers dual-write, deprecation, and removal phases.

Watch for

  • Missing step ordering constraints
  • Skipping consumer impact enumeration
  • Plans that assume zero-downtime without evidence
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.