Skip to content
Back to skills

Database Migrations

ASecurity

Do not do a one-shot `RENAME COLUMN` on a busy `orders` table. Use an expand -> backfill -> contract rollout so old and new code paths can safely coexist. Recommended plan: 1. Expand - Add a new nullable column: `lifecycle_status`. - If queries filter on status, add the matching index for `lifecycle_status` before cutover. - Deploy this schema change first so nothing breaks while application code is still using `status`. 2. Dual-write - Update application writes so any create/update of an ord...

  • 584 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 5, 2026
development

Works with

  • cursor

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill database-migrations --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Database Migrations?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Database Migrations
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-database-migrations/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-database-migrations)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
Do not do a one-shot `RENAME COLUMN` on a busy `orders` table. Use an expand -> backfill -> contract rollout so old and new code paths can safely coexist.

Recommended plan:

1. Expand
   - Add a new nullable column: `lifecycle_status`.
   - If queries filter on status, add the matching index for `lifecycle_status` before cutover.
   - Deploy this schema change first so nothing breaks while application code is still using `status`.

2. Dual-write
   - Update application writes so any create/update of an order writes both `status` and `lifecycle_status`.
   - Keep reads on `status` initially.
   - If possible, guard future read cutover behind a feature flag.

3. Backfill existing rows
   - Run an out-of-band backfill that copies `status -> lifecycle_status` in small resumable batches.
   - Batch by primary key or cursor, not `OFFSET`, to avoid skipped or duplicated work under concurrent traffic.
   - Keep transactions short, throttle between batches if needed, and record progress so the job can resume after interruption.
   - Emit visibility for rows processed, lag remaining, and errors.

4. Verify
   - Check that all rows now have `lifecycle_status` populated.
   - Compare old/new values on a sample and ideally with a mismatch query (`status != lifecycle_status`) to confirm parity.
   - Confirm dual-write keeps both columns in sync for newly updated rows during the rollout window.

5. Cut over reads
   - Switch application reads from `status` to `lifecycle_status` only after backfill verification passes.
   - Continue dual-write for at least one deploy cycle so rollback remains easy.

6. Contract later
   - Once no code reads `status` and monitoring stays clean, remove dual-write.
   - Drop the old `status` column in a separate later migration, not in the same release.

Rollback / pause strategy:

- If the backfill misbehaves, pause the job and keep reads on `status`.
- If the new code causes issues after read cutover, flip reads back to `status`; dual-write preserves compatibility.
- Avoid dropping `status` until the system has run stably on `lifecycle_status` long enough that rollback is no longer needed.

Why this is the safe approach:

- It avoids a destructive rename on a hot table.
- It keeps the app online during schema rollout.
- It makes the backfill observable and resumable.
- It preserves compatibility between old and new application versions during deployment.

Files in this skill

  • eval-1.baseline.md1.8 KB
  • eval-1.with-skill.md2.4 KB
  • trigger-1.md166 B
  • trigger-2.md153 B
  • trigger-3.md130 B
  • trigger-4.md133 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.