Skip to content

Development & Engineering

Migration Plan

Free

Plan a schema or data change as expand, migrate, then contract, without editing applied migrations.

Difficulty advanced
Version v1.1

Purpose

A premium procedure for shipping schema changes that do not strand existing rows.

Procedure

--- name: migration-plan description: Plan a schema or data change as expand, migrate, then contract, without editing applied migrations. ---

Migration Plan

Purpose

A premium procedure for shipping schema changes that do not strand existing rows.

Procedure

Never edit a migration that has already been applied. Add the next numbered file.

For a change that existing rows must survive:

  1. Expand: add the new column or table as nullable or with a temporary default. Deploy code that writes both old and new shapes if the app will run during the change.
  2. Backfill: an update statement that is idempotent (safe to run twice). Do it in the migration only if the table is small and the rule is simple. Say so if a large table should be batched by an operator instead of one lock-heavy update.
  3. Switch reads to the new shape.
  4. Contract: in a later migration, set not-null or drop the old column only after no code reads it.

Do not drop a column in the same migration that introduces its replacement.

Include a rollback note: which step is reversible. Dropping a column is not reversible if you do not have a backup; call that out and do not drop it casually.

User-visible copy and seed content are not a migration unless they live in tables. Do not sneak a data wipe into "cleanup".

State how you will know it worked: a query that counts rows still missing the new value, expected to be zero.

Example requests

1. Add a column

Request: Plan adding a required summary column to an existing skills table that already has rows. Use Migration Plan. Do not delete data. Expected: An expand step that backfills, then a constraint, as new migration files.

Dependencies

None. Work in the repository that is already open. Do not add packages unless the procedure names one.

Compatibility

This document follows the Agent Skills layout (a folder named migration-plan containing SKILL.md). Claude Code, Cursor, Codex, and Gemini CLI can load that file from the paths in the Skilling installation guide. GitHub Copilot does not load SKILL.md. Use the Copilot instructions copy, and narrow applyTo before you commit it.

Example prompts

Add a column

Plan adding a required summary column to an existing skills table that already has rows. Use Migration Plan. Do not delete data.

Expected: An expand step that backfills, then a constraint, as new migration files.

Choose the agent

This skill is installed for one agent at a time. Pick the section you are using.

Related

  • Relational Schema

    Add tables with keys, constraints, and indexes that match the queries you will actually run.

  • Query Scoping

    Scope every read and write of personal rows by the session user, in the query itself.

  • Repro Debugging

    Reproduce a bug with the smallest input, then change one thing and show the before and after.

Reviews

No reviews yet.

    Sign in to review.

    Report a problem

    Inaccurate steps, an unsafe instruction, or a licensing concern.

    Sign in to report.