Alembic Patterns

Identify and fix downgrade issues in Alembic migrations.

4|1|Updated Jan 21, 2026
One-click install
npx skills add https://github.com/ruslan-korneev/claude-plugins --skill alembic-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Alembic Patterns
Source: https://github.com/ruslan-korneev/claude-plugins/tree/main/plugins/fastapi/skills/alembic-patterns
Command: npx skills add https://github.com/ruslan-korneev/claude-plugins --skill alembic-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Alembic migrations often face unsafe downgrades when dealing with enums, nullable changes, and foreign-key constraints. This skill provides automated patterns and guidance to ensure downgrades are safe, deterministic, and reproducible.

Core Features & Use Cases

  • Automatic downgrade handling for enums, including proper deletion of enum types after dropping dependent tables or columns.
  • Safe management of nullable changes, foreign keys, and data migrations during upgrade/downgrade cycles.
  • Practical patterns and examples for creating tables with enums, adding columns with enum types, and handling array fields.

Quick Start

Run alembic revision --autogenerate -m 'auto-fix migrations' and then apply with alembic upgrade head.

Frequently Asked Questions about Alembic Patterns

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

FAQPage Schema
How do I fix Alembic downgrade errors with enums and foreign keys?

To fix Alembic downgrade errors, apply automated patterns that safely manage enum deletions, nullable changes, and foreign-key constraints to ensure reversible migrations. This handles enum types, arrays, and multi-table schemas deterministically.

Why does my Alembic downgrade fail when dropping enum types?

Alembic downgrades fail when dropping enum types if dependent tables or columns are not dropped first. Safe downgrade patterns ensure proper deletion order for enum types across multi-table schemas.

How to handle nullable changes safely in SQLAlchemy Alembic upgrade and downgrade cycles?

Handle nullable changes safely by applying migration patterns that manage data migrations and constraints during both upgrade and downgrade cycles. This ensures nullable modifications are reversible across your schema.

Does this approach support Alembic migrations with array fields and constraints?

Yes, this approach supports Alembic migrations with array fields and constraints by applying patterns across various types including enums, arrays, and foreign-key constraints for safe, reversible schema changes.

What's the best way to generate reversible Alembic migrations automatically?

The best way to generate reversible Alembic migrations is using autogenerate with applied downgrade patterns that validate against sample schemas, providing ready-to-run templates for enums, nullable changes, and foreign keys.