# SQL Migration Safety Analyzer MCP for AI Agents MCP

> SQL Migration Safety Analyzer prevents database disasters by checking your migration scripts for dangerous commands, missing rollbacks, and risky deletions before you run them. It acts as a critical safety net for any database schema change.

## Overview
- **Category:** security
- **Price:** Free
- **Endpoint:** https://edge.vinkius.com/vk_preview_OXY96EmgG6MFqSaJckDKd0LrY7yaTB7ZZQtDfVwz/mcp
- **Tags:** sql, migration, ddl, safety, automation

## Description

The SQL Migration Safety Analyzer acts as a pre-execution check to catch destructive database changes before they hit production. Running a script that accidentally wipes a table or leaves your database in an unrecoverable state is every developer's nightmare. You can feed your migration strings into your agent and have it look for high-risk operations like drops or renames. It also checks if you've actually written the code needed to undo structural changes, so you aren't stuck if something goes wrong. Beyond just schema changes, it scans for dangerous data manipulation commands that lack proper filters, preventing accidental mass deletions. By connecting this to your preferred client through Vintkius, you add a layer of automated auditing to your deployment pipeline without changing your existing workflow.

## Tools

### analyze_migration_security
Scans your migration strings for structural risks like drops or renames. It helps you catch destructive changes early.

### scan_for_unbounded_deletions
Finds high-risk commands that might wipe too much data. This is useful for spotting delete statements without a where clause.

### validate_rollback_integrity
Checks if every structural change has a matching reversal command. It ensures you can always undo your changes.

## Prompt Examples

**Prompt:** 
```
Is this SQL migration safe to run?
```

**Response:** 
```
I've analyzed your script. Here is the risk assessment:

| Risk Level | Found Issues |
| :--- | :--- |
| **CRITICAL** | `DROP TABLE users` detected |
| **HIGH** | Unbounded `DELETE` found |

**Recommendation:** Do not execute this without adding a `WHERE` clause to the delete statement and verifying your backup.
```

**Prompt:** 
```
Check my rollback script for completeness.
```

**Response:** 
```
I checked your migration against your rollback commands. I found one discrepancy:

* **Missing Reversal:** The command `ALTER TABLE orders ADD COLUMN status TEXT` does not have a corresponding `DROP COLUMN` in your rollback block.

Please add the reversal to ensure you can undo this change safely.
```

**Prompt:** 
```
Does this delete statement look dangerous?
```

**Response:** 
```
Yes, this is highly dangerous. The statement `DELETE FROM logs;` lacks a `WHERE` clause. This will wipe every record in the `logs` table immediately upon execution. You should always specify a target range or ID.
```

## Capabilities

### Catch destructive DDL operations
Detects high-risk commands like drops or renames before they execute.

### Verify rollback completeness
Checks that every structural change has a corresponding reversal script.

### Prevent mass data loss
Identifies delete statements that lack proper filters or where clauses.

### Audit migration security
Performs an initial safety check on your entire SQL migration string.

## Use Cases

### A developer pushes a migration that drops a column
They ask their agent to check the script, and it flags the drop command before the deployment runs.

### An engineer forgets a rollback script for an alter table command
The agent identifies the missing reversal command, preventing a one-way structural change.

### A junior dev writes a delete statement without a where clause
The tool detects the unbounded deletion and warns that it could wipe the entire table.

## Benefits

- Stop accidental table drops using `analyze_rag_security` to catch structural risks.
- Ensure every migration is reversible by running `validate_rollback_integrity` on your scripts.
- Avoid massive data loss from unconstrained delete commands found via `scan_for_unbounded_deletions`.
- Automate the security auditing of your SQL deployment scripts.
- Reduce production downtime caused by failed database migrations.

## How It Works

The bottom line is you stop breaking production databases with automated script auditing.

1. Connect your AI client to the MCP via Vinkius.
2. Paste your SQL migration script into your agent's chat.
3. Review the generated risk report for any flagged dangerous operations.

## Frequently Asked Questions

**How can I prevent accidental table drops with SQL Migration Safety Analyzer?**
You can use the MCP to scan your scripts for any `DROP` or `RENAME` commands. It flags these structural risks before you ever run them against your database.

**Can SQL Migration Safety Analyzer help with rollback scripts?**
Yes, it specifically checks if every change in your migration has a matching reversal command, ensuring you can always undo a deployment.

**Will SQL Migration Safety Analyzer detect mass deletions?**
It will. The tool scans for any delete commands that lack proper filters, which helps prevent accidental wipes of entire tables.

**Does SQL Migration Safety Analyzer work with any SQL dialect?**
The analyzer focuses on standard DDL and DML patterns like drops, renames, and unconstrained deletes, making it effective across most major SQL databases.

**How do I use SQL Migration Safety Analyzer in my workflow?**
Simply connect the MCP to your AI client through Vinkius. Once connected, you can just paste your scripts into the chat and ask your agent to audit them for safety.

**How can I check if my migration script contains dangerous DROP commands?**
You can use the `analyze_migration_security` tool. It scans your SQL string for destructive DDL patterns and reports them.

**What does it mean if a migration is flagged as having missing rollbacks?**
It means the tool detected structural changes (like `ALTER` or `RENAME`) that do not have a matching reversal command in your provided rollback script, which you can verify with `validate_rollback_integrity`.

**Can this tool detect dangerous DELETE statements?**
Yes, the `scan_for_unbounded_deletions` tool specifically looks for `DELETE` or `TRUNCATE` commands that lack a `WHERE` clause or are otherwise high-risk.