# Safe DB Migrations: Zero-Downtime Schema Engine

> Zero-downtime, non-locking database migrations and schema evolution for PostgreSQL, MySQL, and SQLite. Prevents production table locks, outage timeouts, and data loss.

Safe DB Migrations: Zero-Downtime Schema Engine is a subscription AI agent skill on Agensi by Tushar, in Data & Databases. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $5.95/mo (subscription, cancel anytime)
- Creator: [Tushar](https://www.agensi.io/creators/tushar)
- Category: [Data & Databases](https://www.agensi.io/skills/data-databases)
- Version: 1.0
- Last updated: 2026-11-22
- Security: scan passed (2026-11-22); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/safe-db-migrations-zero-downtime-schema-engine
- Tags: database, postgres, mysql, prisma, drizzle, sql

## About this skill

### Never Let an AI Agent Crash Your Production Database Again

Every developer has experienced the nightmare: an AI coding agent generates a simple database migration like `CREATE INDEX` or `ALTER TABLE ADD COLUMN NOT NULL`, you run it in production, and seconds later your database connection pool explodes, queries freeze, and your application goes completely offline.

This happens because standard migrations acquire **AccessExclusiveLock** table locks that block all incoming read and write transactions.

**Safe DB Migrations** transforms your AI agent (Claude Code, Cursor, Copilot, Antigravity, or local LLMs) into a senior database site-reliability engineer that guarantees **100% zero-downtime, non-locking migrations**.

---

### What This Skill Solves
- **Eliminates Production Table Locks**: Replaces blocking queries with non-blocking equivalents (e.g. `CREATE INDEX CONCURRENTLY`, lock timeouts).
- **Prevents Outage Cascades**: Mandates `SET lock_timeout = '3s'` and statement timeouts so migrations fail safely instead of starving database connections.
- **Automates Expand-and-Contract**: Provides phased rollout recipes for column renames, type changes, and column drops without breaking running app instances.
- **Guarantees Safe Foreign Keys & NOT NULL**: Implements two-phase `NOT VALID` constraint creation and validation without table rewrites.
- **Throttles Large Backfills**: Batches updates in 5,000-row chunks with sleep yields to prevent WAL bloat and replication lag.
- **Includes Automated Linter CLI**: Bundles `scripts/audit_migration.py` to scan SQL files for 8 dangerous DDL anti-patterns before applying changes.

---

### Supported Databases & ORMs
- **Engines**: PostgreSQL 11+, MySQL 8.0+, SQLite
- **ORMs**: Prisma, Drizzle ORM, TypeORM, Django ORM, Alembic (SQLAlchemy), Supabase, and Raw SQL

## Requires

- Python
- Node.js
- prisma

Runs 100% locally inside your AI coding agent. No database credentials or internet access required. The linter parses raw SQL and ORM files offline.

## Known limitations

Concurrent index operations in Postgres cannot run inside transaction blocks. Requires Python to run the migration audit linter. Backfill logic assumes a primary key for batching.

## 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 Safe DB Migrations: Zero-Downtime Schema Engine skill from Agensi" and describe your task.
3. Subscribe 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

### Does this skill work with Prisma and Drizzle ORM?

Yes! It provides step-by-step guidance on overriding Prisma's default blocking migration DDL with `--create-only` and running concurrent indexing in Drizzle.

### Which database engines and ORMs are supported?

This skill supports PostgreSQL, MySQL, and SQLite. It is compatible with popular ORMs including Prisma, Drizzle, TypeORM, Django, and Alembic, providing either raw SQL or framework-specific migration code.

### Can this skill help with breaking changes like renaming or dropping a column?

Yes, for complex operations like column renames, the skill provides a structured "Expand and Contract" plan. This includes the necessary dual-write logic and multi-step migration scripts to ensure your application stays functional throughout the transition.

### What exactly is included in the purchase of this skill?

You receive the core AI skill protocols for generating safe SQL, a specialized Python-based audit script to lint your migrations for risks, and a library of non-locking migration patterns for various database engines.

### Why should I use this instead of just asking a standard AI to write my SQL?

General-purpose LLMs often suggest simple but dangerous commands (like a standard 'CREATE INDEX') that lock tables. This skill specifically encodes deep database engine behaviors, such as enforcing lock timeouts and ensuring concurrent operations run outside of transaction blocks.

### Are there any specific configuration requirements for my migration runner?

Due to engine-level requirements, PostgreSQL concurrent operations cannot be run inside a transaction block. You will need to ensure your migration runner (like Prisma or Alembic) is configured to allow non-transactional migrations for those specific files.

---

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.
