migration-safety

Generates and reviews reversible database schema migrations for PostgreSQL, MySQL, and SQLite.

Updated Apr 6, 2026
One-click install
npx skills add https://github.com/toderian/project_template --skill migration-safety-toderian
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migration-safety
Source: https://github.com/toderian/project_template/tree/main/plugins/agents-extras/skills/migration-safety
Command: npx skills add https://github.com/toderian/project_template --skill migration-safety-toderian

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Database schema changes on production systems risk table locks, downtime, and irreversible data loss when written carelessly. This Skill generates safe, reversible migrations and reviews proposed ones for hazards like table-rewrite locks, unsafe NOT NULL changes, and missing indexes. ## Core Features & Use Cases - Safe Migration Generation: Produces Liquibase formatted SQL, Flyway, or plain SQL changesets with rollback statements, audit columns, and correct money/timestamp types. - Hazard Review: Detects destructive operations (DROP, renames, type changes), missing CONCURRENTLY on index builds, and NOT NULL additions on populated columns, then enforces a confirmation gate before any destructive change. - Verification & Rollback Plans: Outputs verification SQL assertions, rollback scripts, and a markdown note covering blast radius, lock behavior, and estimated downtime. - Use Case: When adding a foreign key to a populated orders table, the Skill generates a NOT VALID constraint followed by a separate VALIDATE CONSTRAINT step, avoiding an exclusive table lock during deployment. ## Quick Start Ask the agent to write a migration that adds a nullable column with an index to an existing PostgreSQL table, including rollback and verification SQL.

Frequently Asked Questions about migration-safety

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a NOT NULL column to a populated PostgreSQL table?

Adding NOT NULL directly to a populated column causes a table rewrite and lock. Use a multi-phase migration: add the column nullable with a default, backfill in throttled batches, then SET NOT NULL in a separate changeset after the backfill completes.

How to create an index on a large table without downtime?

Use CREATE INDEX CONCURRENTLY in PostgreSQL, which avoids blocking reads and writes, and mark the migration as non-transactional. For MySQL use ALGORITHM=INPLACE, LOCK=NONE; SQLite has no online index build.

Does this work with Liquibase and Flyway migrations?

Yes, it detects Liquibase formatted SQL and Flyway V*__*.sql layouts automatically and generates changesets in the matching style. Liquibase changesets include --rollback statements; Flyway Teams can use U-prefixed undo files.

Why should foreign keys be added with NOT VALID in PostgreSQL?

Adding a foreign key normally takes an exclusive lock while validating every existing row. Adding it NOT VALID skips the scan, then a separate VALIDATE CONSTRAINT step validates existing rows without the exclusive lock.

When is this migration approach not the right fit?

ORM-managed migrations like Alembic, Django, Prisma, or TypeORM have their own conventions, so defer to the framework's idioms while keeping the safety rules. NoSQL stores and warehouses like Snowflake or BigQuery need different playbooks.