Skip to content
Skills Library
Programming · Building & coding

database-migration

/database-migration

Database migrations with Alembic, rollbacks, and zero-downtime deployment. Use for schema changes.

Author
ils15 ↗
Licence
MIT
Last repository change
22.09.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 22.09.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Database migrations with Alembic, rollbacks, and zero-downtime deployment. Use for schema changes.

Original author description

Database migrations with Alembic, rollbacks, and zero-downtime deployment. Use for schema changes.

How it works

  1. Migration Lifecycle
  2. Backward Compatibility Rules
  3. Versioning
  4. Rollback Procedure
Original SKILL.md headings · 111 lines, 306 words
SKILL.md preview
---
name: database-migration
description: "Database migrations with Alembic, rollbacks, and zero-downtime deployment. Use for schema changes."
globs: ["**/alembic/**", "**/migrations/**"]
alwaysApply: false
---

# Database Migration Skill

## Migration Lifecycle

### 1. Generate Migration
```bash
alembic revision --autogenerate -m "Add user preferences"
```

### 2. Review Generated Script
```python
# File: alembic/versions/001_add_user_preferences.py

def upgrade():
    op.create_table('user_preferences',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('user_id', sa.Integer(), nullable=False),
        sa.Column('theme', sa.String(), nullable=True),
        sa.ForeignKeyConstraint(['user_id'], ['user.id']),
        sa.PrimaryKeyConstraint('id')
    )

def downgrade():
    op.drop_table('user_preferences')
```

### 3. Add Indexes
```python
def upgrade():
    op.create_table(...)
    # Add indexes for performance
    op.create_index(
        'ix_user_preferences_user_id',
        'user_preferences',
        ['user_id']
    )

def downgrade():
    op.drop_index('ix_user_preferences_user_id')
    op.drop_table('user_preferences')
```

### 4. Test Locally
```bash
# Test upgrade
alembic upgrade head

# Verify data integrity
SELECT * FROM user_preferences;

# Test downgrade
alembic downgrade -1

# Verify
SELECT COUNT(*) FROM user_preferences;  # Should error
```

### 5. Test on Production-like Data
```bash
# Backup production
pg_dump production > backup.sql

# Load to staging
psql staging < backup.sql

# Run migration
alembic upgrade head

# Performance test
EXPLAIN ANALYZE SELECT * FROM user_preferences WHERE user_id = 123;
```

### 6. Deploy with Zero Downtime
```python
# Strategy 1: Expand-Contract
# 1. Add new column (backward compatible)
# 2. Backfill data
# 3. Deploy code to use new column
# 4. Drop old column

# Strategy 2: Blue-Green
# 1. Deploy new schema to green DB
# 2. Sync data
# 3. Switch traffic to green
# 4. Keep blue as rollback option
```

## Backward Compatibility Rules
- ✅ Add columns with defaults
- ✅ Add tables
- ✅ Add indexes
- ✅ Change column types (with care)
- ❌ Drop columns without deprecation
- ❌ Rename columns without alias
- ❌ Change constraints abruptly

## Versioning
- Never edit old migrations
- Always create new migration
- Migrations are immutable
- Name clearly: `001_initial_schema.py`

## Rollback Procedure
ALWAYS test downgrade first:
```bash
alembic current  # See current version
alembic downgrade -1  # Go back 1 version
alembic upgrade +2  # Forward 2 versions
```

Versions

RepositoryScoreLicence
This page · ils15/copilot-global-config100MIT
rootcastleco/rei-skills100MIT
wshobson/agents100MIT
rmyndharis/antigravity-skills100MIT
HermeticOrmus/LibreUIUX-Claude-Code100MIT
agent-skills-hub/agent-skills-hub100MIT
seb1n/awesome-ai-agent-skills100MIT
jacob-balslev/skill-graph100Apache-2.0
jeffstric/zjt96Apache-2.0

Identical content appears in 2 other GitHub folders. We show one copy with the highest score.

Database snapshot: 13.11.2026 · package version 19760068a5d1 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100database-migration-patterns
    Manage database schema changes safely with migration tools, zero-downtime strategies, and rollback procedures. Covers Alembic, SQL migrations, data migrations, and testing strategies. Triggers on database migration, schema changes, or Alembic configuration requests.
  • 100database-migrations-alembic-flyway
    Use this skill when versioning and deploying zero-downtime database schema migrations using Flyway or Python Alembic.
  • 100database-migrations
    Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs (Prisma, Drizzle, Kysely, Django, TypeORM, golang-migrate). Use when writing a schema or data migration, planning a rollback,…
  • 100database-migrations
    Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs (Prisma, Drizzle, Django, TypeORM, golang-migrate). Use when planning or implementing database schema changes.
  • 100alembic
    Manage database migrations for SQLAlchemy with Alembic. Use when a user asks to version database schemas, autogenerate migration scripts from models, run or roll back migrations, set up async SQLAlchemy migrations, or handle schema changes safely in production.
  • 100database-migration-helper
    Create and manage database migrations safely with rollback support. Use when modifying database schema, adding indexes, or managing database changes.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.