python-migration

Run Alembic migrations with hand-written SQL for zero-downtime schema changes.

1|Updated Jun 20, 2026
One-click install
npx skills add https://github.com/shafibabar/SDLC-Artifact-Factory --skill python-migration
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: python-migration
Source: https://github.com/shafibabar/SDLC-Artifact-Factory/tree/main/skills/python-migration
Command: npx skills add https://github.com/shafibabar/SDLC-Artifact-Factory --skill python-migration

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires alembic, sqlalchemy, asyncpg, and includes references (resource) components.

What problem does it solve?

This skill solves the challenge of evolving database schemas in production environments without causing downtime, data loss, or deployment conflicts.

Core Features & Use Cases

  • Alembic Migration Runner: Provides a disciplined approach to using Alembic as a runner for hand-written SQL, bypassing ORM-based autogeneration.
  • Expand/Contract Pattern: Implements safe, multi-deploy schema changes for breaking modifications like column renaming or adding constraints.
  • Use Case: When a backend engineer needs to add a required column to a large table, this skill guides them through the nullable-add, backfill, and constraint-validation sequence to ensure zero-downtime deployment.

Quick Start

Use the python-migration skill to generate a new hand-written migration revision for the current database schema change.

Frequently Asked Questions about python-migration

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

FAQPage Schema
How do I run zero-downtime PostgreSQL schema migrations without causing locking issues?

Zero-downtime PostgreSQL schema migrations use the Expand/Contract pattern via Alembic to apply hand-written SQL. This ensures backward compatibility by breaking changes into nullable-add, backfill, and constraint-validation sequences without locking tables.

What is the best way to add a required column to a large PostgreSQL table in production?

Adding a required column to a large PostgreSQL table safely requires a multi-deploy sequence. You first add the column as nullable, backfill existing rows, and finally validate and add the constraint to ensure zero-downtime deployment.

Can I use Alembic for hand-written SQL instead of ORM autogeneration?

Yes, Alembic can be used strictly as a migration runner for hand-written SQL. This bypasses ORM-based autogeneration, providing forward-only production discipline and ensuring precise control over iterative database evolution.

Does asyncpg work with Alembic for backend database evolution?

asyncpg works with Alembic and SQLAlchemy as underlying dependencies for backend database evolution. This stack supports CI-verified round-trip testing and decoupled migration-deployment cycles for production-safe schema updates.

When do I need the Expand/Contract pattern for database migrations?

The Expand/Contract pattern is needed for breaking schema modifications like column renaming or adding constraints. It enables safe, multi-deploy schema changes by ensuring old and new application versions can coexist during the migration window.

What are the limitations of using Alembic autogeneration for production database schemas?

Alembic autogeneration lacks the forward-only production discipline required for complex schemas. It often misses multi-step transition logic needed for zero-downtime deployments, making hand-written SQL necessary for safe, backward-compatible database evolution.