# SQL Migration Preflight

> Reviews a SQL migration for data loss, table locks and failed deploys, with the safe rewrite for every risky statement.

SQL Migration Preflight is a free AI agent skill on Agensi by Prateek. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Prateek](https://www.agensi.io/creators/prateek)
- Version: 1.0
- Last updated: 2026-12-04
- Security: scan passed (2026-12-04); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/sql-migration-preflight
- Tags: data-databases, devops-cloud, code-quality-review

## What it does

- Flags DROP, TRUNCATE and unscoped DELETE or UPDATE
- Catches NOT NULL columns and type changes that fail on existing rows
- Warns about index and foreign-key locks on large tables
- Gives an expand-migrate-contract deploy order

## Who it's for

- **Software engineers and developers:** Catch database errors before they crash your production site. Try: "Review this migration: ALTER TABLE users ADD COLUMN phone_number VARCHAR(255) NOT NULL;"
- **Tech leads and senior engineers:** Ensure your team never pushes a migration that locks the main database table. Try: "Review the SQL file in migrations/0042_add_status.sql for safety."
- **Startup founders building their own tech:** Prevent data loss and downtime by checking your database changes first. Try: "Is it safe to run this SQL? DROP COLUMN age FROM customers;"

## About this skill

When you change a database, one wrong line can delete all your user data or freeze your website for hours. This skill acts like a senior database expert that reads your SQL code before you run it. It looks for hidden traps that typical testing misses, like statements that lock tables or changes that cannot be undone.

### How it works
1. You provide a SQL file path or paste the raw SQL code into the chat.
2. Your AI agent runs a specialized check on the code to find dangerous patterns.
3. You receive a clear report showing which lines are safe and which are risky.
4. For every high-risk problem, you get a rewritten version of the code that is safe to use.

### Frameworks & tools
This skill uses a Python script to scan SQL files for patterns like table drops, locks, and index creation.

### Why this beats prompting it yourself
A standard AI often misses specific database locking behaviors or the exact steps needed for zero-downtime deploys. This skill uses a strict, pattern-based script to ensure no dangerous command is overlooked, and it forces a specific "expand and contract" plan for breaking changes that general prompts usually forget.

### Use cases
- Reviewing a migration script before it goes to production
- Finding commands that will freeze a large database table
- Checking if a database change can be safely rolled back
- Planning a column rename without breaking your running app

### Known limitations
This skill cannot see how many rows are in your actual database or check for replication lag. It treats all tables as potentially large and risky.

## Requires

- Python 3.9+

## Technical details

Built to review SQL migrations by running a bundled Python script (review_sql.py) against .sql files. The script uses pattern matching to identify risky statements (DROP, TRUNCATE, ALTER TYPE, etc.) and returns specific severity levels. It generates a structured report including a verdict (BLOCK/REVIEW/SAFE), a findings table, and a three-step deploy plan (expand/migrate/contract) for breaking schema changes. Suitable for integration into CI/CD workflows or manual PR reviews via an AI agent.

## 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 SQL Migration Preflight skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### What does SQL Migration Preflight do?

Reviews a SQL migration for data loss, table locks and failed deploys, with the safe rewrite for every risky statement.

### Which AI agents support SQL Migration Preflight?

This skill uses the open SKILL.md standard. Use it through an MCP-compatible agent connected to Agensi, and check the compatibility information on this page for confirmed agents and required capabilities.

### How do I use SQL Migration Preflight?

Connect your AI agent to Agensi through MCP, then ask it to use SQL Migration Preflight on your task. Your agent loads the latest approved version each time. Paid skills require a purchase or active subscription. Skill files are not available for download; your licence does not allow you to save, copy or export any part of a skill.

---

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.
