Skip to content
Skills Library
Programming · Building & coding

change-data-safely

/change-data-safely

Change a database schema or stored data without breaking running code or losing data. Use this for any migration, new or changed column, backfill, bulk update, delete, index, or change to a stored format, including in small projects. Data mistakes are often impossible to undo.

Licence
MIT
Last repository change
07.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 07.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Change a database schema or stored data without breaking running code or losing data. Use this for any migration, new or changed column, backfill, bulk update, delete, index, or change to a stored format, including in small projects. Data mistakes are often impossible to undo.

Original author description

Change a database schema or stored data without breaking running code or losing data. Use this for any migration, new or changed column, backfill, bulk update, delete, index, or change to a stored format, including in small projects. Data mistakes are often impossible to undo.

How it works

  1. When to use
  2. Steps
  3. Stop and ask when
  4. Common mistakes
  5. Report
Original SKILL.md headings · 77 lines, 570 words
SKILL.md preview
---
name: change-data-safely
description: Change a database schema or stored data without breaking running code or losing data. Use this for any migration, new or changed column, backfill, bulk update, delete, index, or change to a stored format, including in small projects. Data mistakes are often impossible to undo.
---

# Change data safely

Code can be rolled back, but lost data often cannot. During a deploy, old and new
code run against the same data at the same time, so each step must work for both.

## When to use

Any change to stored data or its shape.

## Steps

1. **Read the current state.** Read the schema and existing migrations. Find every
   reader and writer of the affected data.

2. **Ask what already exists.** Think about rows with nulls, duplicates, old
   formats and very large tables. Test against these, not only fresh data.

3. **Split risky changes into stages.**

   | Stage | Action | Safe because |
   | --- | --- | --- |
   | Expand | Add the new column or table, nullable | Old code ignores it |
   | Write both | New code writes old and new | Either version can read |
   | Backfill | Copy old rows in small batches | Can stop and resume |
   | Read new | Switch reads to the new field | Old data is still there |
   | Contract | Remove the old field, in a later release | Nothing uses it now |

   Renaming a column in place breaks whichever code version is not expecting it.

4. **Make each step safe to rerun.** A migration or backfill can stop halfway.
   Running it twice must not corrupt data.

5. **Consider locks and size.** Adding an index or rewriting a large table can block
   production. Use the database's online option, and process rows in batches.

6. **Test it.** Run the migration on a copy of the schema with realistic old rows.
   Run all migrations from empty too. Confirm that row counts and values are right.

7. **Plan recovery.** Write down how to undo each step. If a step cannot be undone,
   say so. Confirm that a recent backup exists and can be restored.

8. **Get approval before production.** Show the exact statements, the affected row
   count and the recovery plan. Do not run them against production without explicit
   approval for that specific action.

9. **Check the result.** Compare counts and sample rows. Then follow
   `verify-and-report`.

## Stop and ask when

- The change deletes or overwrites data, or removes a column or table.
- You are unsure which environment a connection points to.
- There is no tested backup.

## Common mistakes

| Tempting move | Why it fails | Do this instead |
| --- | --- | --- |
| Rename a column in one step | Breaks old or new code | Expand, migrate, contract |
| Add `NOT NULL` with no default | Fails on existing rows | Add nullable, backfill, then constrain |
| `UPDATE` or `DELETE` without a preview | Can hit every row | Run a `SELECT` with the same filter first |
| Update one huge batch | Locks the table | Use small batches |
| Test only on an empty database | Misses real data | Include old-format rows |
| Edit a migration that already ran | Environments drift apart | Add a new migration |

## Report

```markdown
Change: <schema or data change>
Affected: <tables and row counts>
Compatibility: <how old and new code both work during deploy>
Tested on: <data used, and the result>
Recovery: <how to undo, or why it cannot be undone>
Production: <not run / run with approval, and the result>
```

Versions

The database has no other skills named change-data-safely.

Database snapshot: 13.11.2026 · package version e95b2bb46698 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100safe-migration
    Write or review a database migration so it deploys without locking tables, breaking running code or losing data. Works with any SQL database (Postgres, MySQL, SQLite) and any migration tool (Prisma, Drizzle, Rails, Django, Alembic, Knex, Flyway, goose and others). Use when asked…
  • 90add-db-migration
    Use when a ticket requires a database schema change — a new table/column, an index, a constraint, or a backfill. Invoke for "add a migration for X", "alter the schema", or any change to the persisted data model. Schema changes are high-risk; treat them carefully.
  • 100backend-migration-writer
    Authors a safe, reversible database migration — up and down files, data-backfill plan, lock-budget analysis, and rollback strategy. Pulled by the `backend` specialist. TRIGGER: "write the migration for X", "generate the up/down for X column", "add a reversible migration for X",…
  • 100alembic-migration
    Create, review, and apply database schema changes with Alembic. Use whenever a SQLAlchemy model is added or changed, a column/index/constraint needs to change, or a data backfill is required — anything that alters the PostgreSQL schema.
  • 90prisma-migration
    Safely change the Order Hub database schema (prisma/schema.prisma) and create a Prisma migration. Use for any new model, field, index or relation, renames, and data backfills.
  • 100reversible-migration
    Move a schema, data set, API, protocol, configuration or dependency from old to new safely - expand, migrate, verify, then contract - with a rollback path, no data loss and old and new versions working side by side. Use for any migration that existing data, readers or deployed…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.