database-migration-patterns
Master versioned, reversible database migrations that evolve schemas without downtime. Learn Alembic setup, multi-phase column operations, data backfills, and testing strategies to keep applications running during schema changes.
Database Migration Patterns helps you implement safe, reversible schema changes with zero-downtime strategies and Alembic.
AI-generated summary based on this skill's SKILL.md
Install
organvm/a-i--skills/database-migration-patterns · repository language: Python
git clone https://github.com/organvm/a-i--skills
cp -r a-i--skills/skills/development/database-migration-patterns ~/.claude/skills/database-migration-patternsnpx skillfed install organvm/a-i--skills/database-migration-patternsFrequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How to safely migrate database schema without downtime?
database-migration-patterns teaches safe schema evolution through versioned, reversible migrations. The skill covers zero-downtime techniques including multi-phase operations for renames and removals, concurrent index creation, and strategies that prevent table locks. You'll learn to structure changes so applications continue running while schemas evolve, using Alembic's upgrade/downgrade capabilities to maintain control over each transition.
What is Alembic migration setup and configuration?
database-migration-patterns covers Alembic setup from initialization through env.py configuration. You'll learn to initialize Alembic in your project, configure database connectivity, set up version control for migrations, and customize the migration environment. The skill includes best practices for organizing migration files, managing multiple database targets, and configuring Alembic to work safely in production pipelines.
How do you test migration upgrade and downgrade paths?
database-migration-patterns emphasizes testing both directions of every migration before production. The skill teaches frameworks and strategies for validating upgrade paths, ensuring downgrades restore previous state, and catching data loss or corruption early. You'll learn to automate migration testing, verify schema integrity after transitions, and build confidence that rollbacks will succeed if needed.
How can you safely rename a column in production?
database-migration-patterns covers multi-phase column rename patterns that eliminate downtime. The approach involves creating a new column, backfilling data, updating application code to use both columns, then dropping the old column in a later phase. This skill teaches how to coordinate these phases, handle concurrent writes, and validate data integrity throughout the rename process.
What strategies exist for backfilling and transforming data?
database-migration-patterns teaches data migration strategies that run safely during schema evolution. You'll learn to backfill new columns with computed or transformed values, handle large tables in batches to avoid locks, and validate data consistency after transformations. The skill covers techniques for concurrent data changes and ensures backfills don't block application traffic.
How do you prevent table locks during schema changes?
database-migration-patterns addresses lock prevention through techniques like concurrent index creation, non-blocking column additions, and multi-phase operations. The skill teaches database-specific approaches (PostgreSQL, MySQL) for avoiding exclusive locks, batching large changes, and structuring migrations so applications remain responsive. You'll learn to monitor lock contention and adjust strategies for your database platform.
SKILL.md
rendered from the published skill — quoted content, verbatim
Database Migration Patterns
Evolve database schemas safely with versioned, reversible, tested migrations.
Alembic Setup
# Initialize
alembic init alembic
# Create migration
alembic revision --autogenerate -m "add skills table"
# Run migrations
alembic upgrade head
# Rollback one step
alembic downgrade -1
# Show current state
alembic current
alembic history
Configuration
```python
alembic/env.py
from app.models import Base from
(truncated - see the full file via the links below)
Read as markdown · JSON record · Browse the source repository
File tree — 1 file
skills/development/database-migration-patterns/SKILL.md