database-migration

Generate idempotent PostgreSQL migration scripts for Supabase schema changes.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/contechjohnson/MCB --skill database-migration-contechjohnson
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migration
Source: https://github.com/contechjohnson/MCB/tree/main/.claude/skills/database-migration
Command: npx skills add https://github.com/contechjohnson/MCB --skill database-migration-contechjohnson

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Generate robust SQL migrations for Supabase/PostgreSQL to safely evolve schemas, ensure idempotency, and maintain data integrity.

Core Features & Use Cases

  • Migration templates: Provides structured, repeatable migration patterns for creating tables, adding columns, creating indexes, and enforcing constraints.
  • Safe, idempotent operations: Encourages using IF NOT EXISTS, transactions, and helpful comments to prevent duplicate changes and enable rollback.
  • Use Case: When you need to introduce a new table or modify an existing schema without risking data loss, use this skill to generate the corresponding SQL migration with best practices.

Quick Start

Provide a complete, idempotent migration script with comments for the requested schema changes.

Frequently Asked Questions about database-migration

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

FAQPage Schema
How do I generate safe PostgreSQL migrations for Supabase?

Generate safe PostgreSQL migrations by producing transaction-wrapped SQL scripts that modify tables, columns, and indexes. The generated migrations validate idempotency using IF NOT EXISTS clauses and include descriptive comments to prevent duplicate schema changes.

What's the best way to make PostgreSQL schema migrations idempotent?

Make PostgreSQL schema migrations idempotent by using IF NOT EXISTS clauses within transaction blocks. This prevents duplicate execution errors when adding tables, columns, or indexes, ensuring the migration runs safely multiple times without data loss.

Why does my PostgreSQL migration fail when adding columns to an existing table?

PostgreSQL migrations fail when adding columns if the schema change lacks idempotency checks or transaction safety. Using IF NOT EXISTS clauses and wrapping modifications in transaction blocks ensures data integrity and prevents execution errors during deployment.

Can I use this to create database indexes safely in a CI pipeline?

Yes, you can use this to create database indexes safely in a CI pipeline. It generates structured, repeatable migration patterns using transaction blocks and idempotent operations suitable for typical development workflows and production deployment processes.

When do I need transaction blocks for SQL schema changes?

You need transaction blocks for SQL schema changes when modifying tables, columns, or constraints to maintain data integrity. Wrapping operations in transactions enables safe rollback if the migration fails, preventing partial schema updates in production.

Does this approach work for enforcing constraints in PostgreSQL without risking data loss?

Yes, this approach works for enforcing constraints in PostgreSQL without risking data loss. It generates structured SQL migrations that apply constraints safely using transaction blocks and idempotent operations to ensure data integrity during schema evolution.