agentleFS
ychampionychampion/ystack/skills/migration-plan/SKILL.md

migration-plan

Skill4 starsChanged 2 days agoMITView on GitHub

Plan a schema or data change that is safe to deploy and to undo: split it into expand / backfill / switch / contract steps that each work with old and new code running at once, write a rollback for every step, rehearse on a copy of real data with row counts, and set the checks that decide go or stop. Use for "add/rename/drop a column", "migrate this data", "change the schema", "backfill", "change a file or message format", "is this migration safe", or any change to stored data.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

6 rules. 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write the before and after shape, how many rows or files are affected (query it), and who reads and writes this data: services, jobs, other …

    line 25
  2. Very specific:

    Use expand and contract. A rename of email to contact_email, for example:

    line 30
  3. Distinctive:

    Run the steps on a copy of real data (or a realistic sample at scale).

    line 53
  4. Distinctive:

    Every step before the point of no return has a tested rollback.

    line 73
  5. Distinctive:

    No step requires old and new code to be deployed at the same instant.

    line 74
  6. Distinctive:

    Never rewrite data in place without a copy or backup you have restored at least once.

    line 75

“Common” is measured: kept by at least 6 in 10 of the 4 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Migration plan

Code rolls back in a minute. Data, once rewritten, often can't. Plan every data change so that each step can be deployed alone, can run while old code is still live, and has a way back.

When it applies

  • Any change to a database schema, stored file format, cache layout, queue message shape or index.
  • A backfill or bulk rewrite of existing data.

Procedure

1. State the change and the data

Write the before and after shape, how many rows or files are affected (query it), and who reads and writes this data: services, jobs, other repos, analytics, backups.

2. Split into steps that each stand alone

Use expand and contract. A rename of email to contact_email, for example:

StepChangeOld code still works?Rollback
1 Expandadd contact_email, nullableyesdrop the column
2 Dual writecode writes both columnsyesdeploy previous code
3 Backfillcopy email to contact_email in batchesyesnone needed: old column intact
4 Switch readscode reads contact_emailyesdeploy previous code
5 Contractstop writing email, later drop itno: point of no returnrestore from backup only

Each step ships separately. Mark the point of no return and put it last, after a waiting period.

3. Make the risky steps safe

  • Locks: know whether the change locks the table on your database and size; use the online or concurrent form where it exists (adding indexes, adding columns with defaults).
  • Backfills: batches of a fixed size, resumable from the last id, safe to run twice, throttled.
  • Defaults and nulls: decide what old rows get; never let "null" silently mean something new.
  • Backup: confirm a restorable backup exists before the point of no return. Check the restore, not just the backup file.

4. Rehearse on a copy

Run the steps on a copy of real data (or a realistic sample at scale). Record time per step and row counts before and after. Run the rollback for each step and check the data matches the start.

5. Set go and stop checks

For each step: the query or metric that shows it worked (row counts match, no nulls where none are allowed, error rate flat), and the condition that means stop and roll back.

Output

Change: <before -> after>   Affected: <n rows/files>   Readers/writers: <list>
Steps: <the table, with rollback per step>
Point of no return: step <n>, after <wait condition>
Rehearsal: <time per step, counts before/after, rollback tested yes/no>
Checks: <per step: go signal / stop signal>

Rules

  • Every step before the point of no return has a tested rollback.
  • No step requires old and new code to be deployed at the same instant.
  • Never rewrite data in place without a copy or backup you have restored at least once.
  • Running the plan against production is the user's call; hand over the plan.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.