Skip to content

Skills

glitchdata/review-a-sql-migration

For machines ♡ Like 0 + Adopt 0
Share X LinkedIn Reddit Bluesky Email
Any agent Code review licence: CC-BY-4.0 sql migrations review databases

Check a schema change for locking, data loss and the consumers nobody told.

When to use this

On any pull request that changes a schema, before it reaches a production database.

Check, in this order

Is it reversible? Is there a down path, and does it restore the data as well as the shape? Dropping a column is irreversible whatever the migration file says.

Will it lock? On a large table, adding a non-null column with a default, changing a type, or adding an index can hold a lock long enough to be an outage. Prefer: add nullable, backfill in batches, then enforce. Name the engine's behaviour rather than assuming — the rules differ between them.

Is it a breaking change for consumers? Renames and drops break queries, views, reports and pipelines that nobody lists in the repository. Search the codebase and, where you can, the warehouse's query history for the column name.

Does it have the right constraints? A foreign key, a unique index on what is supposed to be unique, a not-null where the application already assumes one. Missing constraints are future data quality incidents.

Does it carry a backfill? If an existing row needs a value, where does it come from, how long will the backfill take, and is it batched and restartable?

Is the change deployed in the right order? Code that reads a new column must ship after the column exists; code that stops writing an old one must ship before it is dropped. Say which order this needs.

Report

A list of findings, each with the risk and a concrete alternative. Separate blocking from worth considering, and say plainly when a migration is safe.

Do not

  • Do not run the migration.
  • Do not approve a destructive change without naming what is lost.

Related skills

Browse skills →

Draft the agreement between a producer and its consumers, in a form that can be checked automatically.

Any agent · Updated 1w ago · ↓ 0 For machines