# migration-guard

> Catches the database migrations that lock tables or lose data — before they hit production.

migration-guard is a paid AI agent skill on Agensi by J. Shtal, in Data & Databases. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $10 (one-time purchase)
- Creator: [J. Shtal](https://www.agensi.io/creators/julia-shtal)
- Category: [Data & Databases](https://www.agensi.io/skills/data-databases)
- Version: 1.1
- Last updated: 2026-07-02
- Security: scan passed (2026-07-02); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/migration-guard
- Tags: code-review, migrations, postgres, backend, mysql, oracle

## About this skill

### The problem

Database migrations that work fine in development often lock tables, lose data, or break production during a rolling deploy. Standard CI catches syntax errors — it rarely catches a CREATE INDEX that freezes writes for ten minutes, or a RENAME that breaks the app version still running the old code.

### What it does

- Reviews SQL, Flyway, and Liquibase migrations for Postgres, MySQL, and Oracle against ~48 dialect-specific safety rules.

- Flags blocking DDL (non-concurrent indexes, table rewrites, unvalidated constraints), data loss (DROP, TRUNCATE, UPDATE without WHERE), and zero-downtime hazards (RENAME, backfills, missing lock_timeout).

- Rewrites unsafe migrations into a safe, ordered sequence — expand-contract, batched backfills, two-step constraint validation — instead of just flagging the problem.

- Outputs text for local review, or JSON/SARIF for CI gates and GitHub code scanning.

### Why it's worth having

These are well-known traps, but they're easy to miss in a normal code review — nobody reads a migration file thinking about ACCESS EXCLUSIVE locks on a 100M-row table. migration-guard encodes that expertise so your agent (and your CI) catches it every time, not just when someone remembers to check.

### Example

`ALTER TABLE orders ADD COLUMN status text NOT NULL;` looks harmless. migration-guard flags it as a BLOCKER (forces a full-table rewrite under an exclusive lock) and rewrites it into three safe migrations: add the column nullable, backfill in batches, then enforce NOT NULL via a validated check.

### Free vs full

A free edition covering BLOCKER-level lock and data-loss rules is available on [GitHub](https://github.com/julia-shtal/migration-guard-free). This full edition adds every CRITICAL/WARNING rule, the zero-downtime rewrite engine, MySQL support, and JSON/SARIF output for CI.

## Known limitations

Static analyzer only — it reads SQL, not your database. It doesn't know actual table sizes, so when an operation would rewrite a table and the size is unknown, it errs toward warning rather than guessing.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the migration-guard skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does migration-guard differ from standard linting or CI database checks?

migration-guard analyzes your SQL, Flyway, or Liquibase scripts to identify dangerous operations like table-locking DDL or accidental data loss that standard CI tools often miss. It doesn't just flag errors; it actually provides a rewritten, safe sequence of migrations to ensure zero-downtime deployments.

### Which database engines are supported by the migration-guard logic?

This skill supports PostgreSQL, MySQL, and Oracle databases, using over 48 dialect-specific safety rules to ensure the suggested rewrites are compatible with your specific environment.

### What are the main differences between the full edition and the free version on GitHub?

This full version includes the complete library of CRITICAL and WARNING rules, the automated rewrite engine for zero-downtime sequences, MySQL support, and professional output formats like JSON/SARIF for CI/CD integration.

### Can I integrate migration-guard into my existing CI/CD pipeline?

Yes, the skill can output findings in SARIF or JSON formats, making it easy to integrate into GitHub Code Scanning, GitLab CI, or custom automation pipelines to block unsafe PRs.

### Which AI agents or environments can I use this skill with?

migration-guard is designed to work as a standalone CLI tool or as a specialized skill for AI coding agents and DevOp assistants that handle pull requests and database schema changes.

### How does the 'rewrite' engine handle a migration that would normally lock a large table?

The skill handles complex scenarios like adding 'NOT NULL' columns or renaming tables by breaking them into multi-step 'expand-contract' patterns, such as adding nullable columns first and validating constraints later.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
