add-migration

Generate idempotent Alembic migrations for PostgreSQL schema changes.

Updated Feb 3, 2026
One-click install
npx skills add https://github.com/michaelayoade/dotmac_crm --skill add-migration-michaelayoade
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: add-migration
Source: https://github.com/michaelayoade/dotmac_crm/tree/main/.claude/skills/add-migration
Command: npx skills add https://github.com/michaelayoade/dotmac_crm --skill add-migration-michaelayoade

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you create database schema changes that can be applied repeatedly without breaking your environment, reducing deployment risk across development, staging, and production.

Core Features & Use Cases

  • Idempotent Alembic upgrade logic: Ensures tables, columns, enums, and indexes are only created/added when missing, including safe handling for partial unique indexes via PostgreSQL-style SQL.
  • PostgreSQL enum safety: Guides correct handling when adding enum values, including transaction caveats and create_type=False patterns.
  • Operational readiness: Emphasizes including a downgrade path and testing the migration by applying it and re-running to confirm it becomes a no-op.

Quick Start

Ask your AI to generate an Alembic migration for the change you need and ensure the resulting upgrade and downgrade functions are written to be safe to run multiple times.

Frequently Asked Questions about add-migration

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

FAQPage Schema
How do I make Alembic migrations idempotent for PostgreSQL schema changes?

To make Alembic migrations idempotent, implement existence checks for tables, columns, indexes, and enums so they only execute when missing. This ensures safe re-runs during CI-driven rollouts without breaking environments.

How do I safely add enum values in SQLAlchemy without deployment errors?

Safely adding PostgreSQL enum values requires handling transaction caveats and using create_type=False patterns in SQLAlchemy. This prevents deployment errors by ensuring the enum type is not unnecessarily recreated during schema adjustments.

What is the best way to handle partial unique indexes in PostgreSQL migrations?

Handling partial unique indexes in PostgreSQL migrations involves using specific PostgreSQL-style SQL within your Alembic upgrade logic. This approach safely manages index creation by incorporating existence checks to avoid duplicate indexing errors.

Does an Alembic migration need a downgrade path for CI-driven deployments?

An Alembic migration needs a downgrade path for CI-driven deployments to ensure operational readiness. Including a downgrade function allows you to safely revert schema changes if the deployment encounters unexpected issues.

How do I test if a database migration is truly repeatable?

To test if a database migration is repeatable, apply the migration and then re-run it to confirm the second execution becomes a no-op. This verifies the idempotent upgrade logic correctly handles existing schema elements.