SQL migration safety check for PostgreSQL, MySQL and SQLite
Flags risky statements in SQL migrations before deploy: drops, UPDATE or DELETE without WHERE, NOT NULL without default, long locks and rewrites, missing IF EXISTS.
What it does
Reads migration files before they run in production and flags risky statements with the reason and a safer alternative. It never connects to a database.
- Data loss:
DROP TABLE,DROP COLUMN,DROP DATABASE,TRUNCATE,UPDATEorDELETEwithout a top-level WHERE (a WHERE inside a sub-query does not count) - Fails on tables with data:
NOT NULLcolumn without DEFAULT,SET NOT NULL, new UNIQUE, primary or foreign keys - Locks and rewrites: column type changes, PostgreSQL index builds without
CONCURRENTLY,CREATE INDEX CONCURRENTLYinside a transaction, constraints withoutNOT VALID,VACUUM FULLand more - Breaks running code: table and column renames
- SQLite specifics: unsupported ALTER forms, non-constant defaults, table-rebuild pattern detection,
PRAGMA foreign_keys - Re-run failures: missing
IF EXISTSorIF NOT EXISTS --big-tablesraises severity for large tables; tables created in the same file and down migrations are lowered
How to use
python scripts/migration_check.py migrations/ --big-tables users,orders --json migration-review.json
The agent then checks table sizes, database version and code references, and proposes safe sequences such as expand and contract.
Requirements
- Python 3 (standard library only)
Caveats
- Static review: data-dependent failures (duplicates, NULLs) cannot be detected.
- Dialect detection is a guess; pass
--dialectwhen you know it. - It is not a full SQL parser, so unusual syntax may be split into statements incorrectly.
How to install
- Unzip the downloaded file (it contains a
sql-migration-safety-check/folder withSKILL.md). - Copy the whole folder into your agent's skills folder.
- Claude:
~/.claude/skills/(per project:.claude/skills/) - Hermes Agent:
~/.hermes/skills/ - Codex:
~/.agents/skills// Cursor:~/.cursor/skills/ - Claude app (claude.ai): upload the ZIP in Customize → Skills
- Claude:
- Restart the agent and check that the skill appears in its skill list.
Seller
AI Skill Market (official)
44 published skills