rockclaver/systemcraft

safe-schema-migrations

Plan zero-downtime, reversible schema and data migrations via expand/contract, online DDL, and batched backfills. Use when adding/dropping/renaming columns, changing types/constraints, backfilling, or migrating large ledger tables.

First seen Jun 11, 2026

Installation

$ npx skills add rockclaver/systemcraft --skill safe-schema-migrations

Similar popular skills

Related neighbors and high-traction skills in the same topics — useful to compare before installing.

Also in this package

Other skills from rockclaver/systemcraft · top by installs.

npx skills add rockclaver/systemcraft

Browse all from rockclaver/systemcraft

More details

Agent compatibility

Declared targets from SKILL.md / docs. Unmarked agents are not listed — the skill may still install via the CLI.

Claude Code Not declared
Cursor Not declared
Codex Not declared
GitHub Copilot Not declared
Windsurf Not declared
Gemini CLI Not declared
Cline Not declared
OpenCode Not declared

Repository health

Default branch main
Open issues 0
Status Active

Package contents

Files included with this skill beyond the listing page.

  • skill md SKILL.md 2,723 B
  • docs SUMMARY.md 261 B

History

  1. First seen on skills.sh
  2. First recorded snapshot · 5 installs

SKILL.md

Safe Schema Migrations

Change the schema without downtime, locks on hot tables, or irreversible steps. Treat the migration and the code deploy as coordinated steps, not one big switch. Pair with financial-invariants for data correctness and scale-readiness-review for sizing impact.

Workflow

1. Classify the change

  • Additive (nullable column, new table/index): lowest risk.
  • Backfill: risk is runtime and lock duration.
  • Constraint/type change (NOT NULL, FK, widen/narrow): risk is table locks and rewrites.
  • Rename/move: never in place under a running app — expand/contract instead.
  • Destructive (drop): only after no code references it for a full deploy cycle.

2. Expand / contract

Each phase ships independently and is reversible; the app is never broken between steps:

  1. Expand: add the new structure without removing the old.
  2. Migrate code: write both, read old (or read new behind a flag).
  3. Backfill: populate existing rows in batches.
  4. Switch reads: read new; keep dual-write briefly.
  5. Contract: stop writing old; add constraints; drop old structure last.

3. Keep DDL online

  • Create indexes concurrently/online where supported.
  • NOT NULL via checked constraint validated separately, or default-then-enforce.
  • FKs as NOT VALID, then VALIDATE separately.
  • Keep DDL transactions short; never hold locks during heavy work.

4. Backfill safely

  • Bounded, ordered batches (by id/date) with a small sleep between; resumable and idempotent.
  • Run as a job/script, never inside the schema migration transaction.
  • Monitor lock contention, replication lag, batch duration; throttle if they grow.

5. Rollback plan

  • Every step has a down path or documented forward-fix.
  • Destructive steps live in a separate, later migration so rolling back the latest deploy loses no data.

6. Verify

  • Test on production-scale row counts; measure lock time and duration.
  • Run the test suite against the migrated schema at each phase; apply down-then-up where a down path exists.
  • Financial tables: reconcile row counts and key sums before and after backfill.

Guardrails

  • Never rename or drop a column in the same deploy that stops using it.
  • Never backfill a large table in one transaction.
  • Never add NOT NULL or a validating FK that full-table-locks a hot table.
  • Never run destructive DDL while running code references the old structure.