uniswap/ai-toolkit/analyze-migrations

Claude Code and agent skill by uniswap/ai-toolkit

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Analyze database migration files for safety issues before applying them to production. Use when the user says "check my migrations for safety issues", "review my database migrations", "are these migrations safe to run in production", "analyze my schema changes for locks or data loss", "scan my migration files for dangerous patterns", or "will this migration cause downtime".

Install

npx vskill@latest install uniswap/ai-toolkit/analyze-migrations

SKILL.md

Migration Safety Analyzer

Statically analyze database migration files to detect patterns that cause table locks, data loss, or production outages before they reach production.

Step 1: Detect migration framework and locate files

Scan the repository for migration file patterns:

FrameworkPath patternFile pattern
Prismaprisma/migrations/migration.sql
Rails/ActiveRecorddb/migrate/*.rb
Django*/migrations/[0-9]*.py
Flywaysrc/main/resources/db/migration/, migrations/, db/V*.sql, R*.sql
Alembicalembic/versions/, migrations/versions/*.py
Drizzledrizzle/, src/db/migrations/*.sql
TypeORMsrc/migrations/, migrations/*.ts, *.js
Liquibasesrc/main/resources/db/changelog/*.xml, *.yaml, *.sql

If the user specifies a path or framework, use that. Otherwise auto-detect by searching for these patterns with Glob and Grep.

Report which framework was detected and how many migration files were found. If no migrations are found, report that clearly and stop.

Scope: analyze the 20 most-recent migrations by filename sort order (timestamp prefix is standard for all frameworks). If the user requests a specific migration or range, use that instead.

Step 2: Build migration inventory

For each migration file in scope:

  • Record the filename, detected framework, and direction (up/forward/apply vs. down/rollback/revert)
  • Note whether a corresponding rollback migration exists (critical gap if missing for destructive operations)
  • Extract the raw SQL or ORM operation list

For ORM-based migrations (Rails, Django, Alembic, TypeORM), translate operations to their SQL equivalents before analysis:

  • add_column → ALTER TABLE ... ADD COLUMN
  • remove_column → ALTER TABLE ... DROP COLUMN
  • change_column / alter_column → ALTER TABLE ... ALTER COLUMN
  • add_index → CREATE INDEX
  • create_table → CREATE TABLE

Step 3: Static safety analysis

Analyze each migration for the following patterns. Evaluate against both PostgreSQL and MySQL semantics unless the stack is known.

The three tables below are a starting checklist, not an allowlist. They cover the common cases; they do not enumerate every way a migration can lock a table or lose data. If a migration does something dangerous that no row describes — a stored-procedure change, a partition swap, a trigger that rewrites rows, a vendor-specific DDL — report it anyway at the severity you judge appropriate and say it was found outside the checklist. A finding you drop because it has no matching row is a production incident the report failed to prevent.

CRITICAL — causes table locks or data loss
PatternRiskDetection
ADD COLUMN ... NOT NULL without DEFAULTFull table rewrite lock (PostgreSQL < 11, MySQL < 8.0)SQL: ADD COLUMN + NOT NULL + no DEFAULT; Rails: add_column with null: false and no default:
DROP COLUMNIrreversible data lossSQL: DROP COLUMN; Rails: remove_column; Django: RemoveField
DROP TABLEIrreversible data lossAny framework
TRUNCATEIrreversible data lossSQL keyword scan
ALTER COLUMN type changeData corruption or lockType mismatch (e.g., varchar → int, text → varchar(255) shrink)
RENAME TABLE without deploy coordinationApp breakage during deploySQL: RENAME TABLE, ALTER TABLE ... RENAME TO
WARNING — potential downtime or deployment risk
PatternRiskDetection
Missing rollback migrationCannot undo if deploy failsNo corresponding down/revert file for migration with destructive ops
FK column without indexSlow queries and lock escalationREFERENCES keyword or ForeignKeyConstraint without subsequent CREATE INDEX on the referencing column
RENAME COLUMN without multi-phase deployApp reads old name during deploy windowSQL: ALTER TABLE ... RENAME COLUMN; Rails: rename_column
Enum type changesBreaks existing values or requires lockALTER TYPE ... ADD VALUE, ENUM(...) redefinition, choices= changes in Django without migration
ALTER TABLE adding index without CONCURRENTLY (PostgreSQL)Table lock during index buildCREATE INDEX without CONCURRENTLY; add_index without algorithm: :concurrently
ALTER TABLE without ALGORITHM=INPLACE, LOCK=NONE (MySQL)May fall back to full copyMySQL-targeted migrations using ALTER TABLE on large tables
Bulk UPDATE / DELETE without batch limitLock escalation and long transactionSQL: UPDATE ... WHERE or DELETE ... WHERE without LIMIT; row estimate > 10k
NOT NULL constraint added to existing columnRequires full table scanChanging existing nullable column to NOT NULL without prior data cleanup
INFO — worth reviewing
PatternRiskDetection
New unique constraintLock during validationADD CONSTRAINT ... UNIQUE, add_index unique: true
ADD COLUMN with DEFAULT expression (non-literal)May evaluate per-rowDEFAULT now(), DEFAULT gen_random_uuid() on large tables
Migration with no rollback and no destructive opsLow risk but noteStandard informational
Multiple DDL statements in one migrationHarder to retry on failureCount ALTER TABLE, CREATE, DROP statements

Step 4: Generate safety report

Structure the output as a migration safety report grouped by severity.

Header: framework detected, files analyzed, analysis date.

CRITICAL findings (if any): formatted as:

[CRITICAL] <migration-filename>:<line>
Pattern: <what was found>
Risk: <what can go wrong in production>
Safe alternative:
<concrete rewrite or multi-step approach>

WARNING findings: same format with severity label.

INFO findings: condensed list, one line per finding.

Summary table:

| Severity | Count | Migration Files Affected |
|----------|-------|--------------------------|
| CRITICAL | N | file1.sql, file2.rb |
| WARNING | N | ... |
| INFO | N | ... |

Verdict:

  • No CRITICAL and no WARNING → SAFE TO DEPLOY
  • No CRITICAL but WARNING(s) present → DEPLOY WITH CAUTION — review WARNING findings
  • Any CRITICAL unresolved → BLOCKED — resolve CRITICAL findings before deploying

For each CRITICAL and WARNING finding, provide a concrete safe alternative. Examples:

  • ADD COLUMN NOT NULL without default → add nullable first, backfill data, then add NOT NULL constraint in a separate migration
  • DROP COLUMN → use a multi-phase approach: deprecate in app code, verify no reads/writes, then drop in a later migration
  • Missing CONCURRENTLY on index → use CREATE INDEX CONCURRENTLY with disable_ddl_transaction! (Rails) or op.execute("CREATE INDEX CONCURRENTLY ...") (Alembic)
  • RENAME COLUMN → use expand/contract: add new column, dual-write in app, backfill, switch reads, remove old column

Success criteria

  • Detected the correct migration framework
  • Analyzed all in-scope migration files
  • Identified all CRITICAL patterns with specific file and line references
  • Provided concrete safe alternatives for every CRITICAL and WARNING finding
  • Delivered a clear SAFE / BLOCKED / CAUTION verdict

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
43
Repository forks
12
7-day trend score
19

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/uniswap/ai-toolkit/analyze-migrations/badge)](https://verified-skill.com/skills/uniswap/ai-toolkit/analyze-migrations)

Something wrong with this skill or its page? Tell us.