agentleFS
vmobifystudiovmobifystudio/app-dev-team/skills/database-migration/SKILL.md

database-migration

Skill5 starsChanged 8 days agoMITView on GitHub

On an app-dev-team project, use before changing any persisted schema — the first column, field, index or model change, not the deploy. Covers server databases and on-device stores (Room, SwiftData, Core Data, GRDB, IndexedDB). Used by backend-developer, web-developer, ios-developer, android-developer, code-reviewer and reliability-engineer.

30 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use security-audit, mcp-builder and 1 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • CloudflareSkill

    security-audit

    Security guidance and vulnerability review for codebases, APIs, services, CLI tools, libraries, and daemons. Use for security questions, focused reviews, vulnerability research, security audits, or pen tests. Run the complete workflow only for explicit codebase audit or pen-test requests, full/comprehensive/end-to-end reviews, or requested report artifacts.

    Also in 3 projects that use this

  • MicrosoftSkill

    mcp-builder

    Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

    Also in 3 projects that use this

  • GoogleSkill

    code-review

    Adversarial systems, concurrency, memory-model, and architecture code review protocol. Use this skill whenever asked to review code, PRs, diffs, or branches in Filament.

    Also in 4 projects that use this

The file

We split this skill into the rules it gives an agent

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

  • 0

    Common

    Most of the 21 edited versions we read keep these.

  • 5

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Say how you roll back: If the answer is "restore a backup", say that explicitly — it is a real answer, and it changes the deploy plan.

    line 25
  2. Distinctive:

    Forward-only, versioned, and ordered: Never edit a migration that has run anywhere.

    line 30
  3. Distinctive:

    Run it against a copy of real-shaped data with the awkward rows in it — nulls, duplicates, the pre-unicode row, the one from the first …

    line 41
  4. Distinctive:

    Run it twice and confirm the second run is a no-op.

    line 44
  5. Distinctive:

    Run the previous application version against the migrated schema.

    line 45

“Common” is measured: kept by at least 6 in 10 of the 21 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

Database migration

A migration is the one change that cannot be rolled back by reverting the commit. Code reverts; data that has already moved does not. Treat every migration as one-way until you have proven otherwise.

Where a platform skill exists, use it — axiom:axiom-database-migration, axiom:axiom-swiftdata-migration, or the auditor for your store. External and optional; missing → follow this file.

Before you write it

  1. Enumerate every writer and every reader of the affected data (defect-hunting §1). The migration that stops one layer short is FC-001, and this is the surface where it costs most.
  2. Name the old and new shape explicitly, including what happens to rows that violate the new constraint today. There are always some.
  3. Decide expand or contract. Almost always expand first:
    • Expand: add the new column nullable, write both, backfill, read new with fallback to old.
    • Contract: only after every deployed client and server writes the new shape. On mobile that means after the oldest supported app version is gone, which is months, not the next sprint.
  4. Say how you roll back. If the answer is "restore a backup", say that explicitly — it is a real answer, and it changes the deploy plan.

Writing it

  • Forward-only, versioned, and ordered. Never edit a migration that has run anywhere.
  • Idempotent: safe to run twice, because it will be.
  • Transactional where the engine allows it, and where it does not (many ALTER TABLE paths), say so and make each step independently safe.
  • Never DROP in the same release that stops using the column. Two releases, minimum.
  • Backfill in batches with a bound, not in one statement that locks the table.
  • A NOT NULL column gets a default or a backfill in the same migration — this is the single most common way a migration fails in production and not in dev.

Proving it

  • Run it against a copy of real-shaped data with the awkward rows in it — nulls, duplicates, the pre-unicode row, the one from the first version. A migration tested only on a fresh database has been tested on the one case that never occurs.
  • Run it twice and confirm the second run is a no-op.
  • Run the previous application version against the migrated schema. During any rollout both exist at once, and this is the check that catches it.
  • Count rows before and after, and state both. "It seemed to work" is not a result.

Output

The migration file, plus in the ticket: old shape, new shape, expand-or-contract, rollback plan, row counts before and after, and the awkward-data cases you ran it against.

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.