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.

ClaudeHermes AgentCodexCursorMIT (modify, redistribute and use commercially)Python

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, UPDATE or DELETE without a top-level WHERE (a WHERE inside a sub-query does not count)
  • Fails on tables with data: NOT NULL column without DEFAULT, SET NOT NULL, new UNIQUE, primary or foreign keys
  • Locks and rewrites: column type changes, PostgreSQL index builds without CONCURRENTLY, CREATE INDEX CONCURRENTLY inside a transaction, constraints without NOT VALID, VACUUM FULL and 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 EXISTS or IF NOT EXISTS
  • --big-tables raises 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 --dialect when you know it.
  • It is not a full SQL parser, so unusual syntax may be split into statements incorrectly.

How to install

  1. Unzip the downloaded file (it contains a sql-migration-safety-check/ folder with SKILL.md).
  2. 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
  3. Restart the agent and check that the skill appears in its skill list.

Step-by-step install for Windows / Mac and each agent

Seller

AI Skill Market (official)

44 published skills

Seller profile and all skills