alembic
Manage database migrations with Alembic. Use when a user asks to version database schemas, create migration scripts, handle schema changes in production, or manage SQLAlchemy model migrations.
What this skill does
# Alembic
## Overview
Alembic is the migration tool for SQLAlchemy. It tracks database schema changes as versioned Python scripts — like Git for your database. Supports autogeneration from model changes, branching, and data migrations.
## Instructions
### Step 1: Setup
```bash
pip install alembic
alembic init alembic
```
```python
# alembic/env.py — Configure with async SQLAlchemy
from alembic import context
from sqlalchemy.ext.asyncio import create_async_engine
from models import Base
import asyncio
config = context.config
target_metadata = Base.metadata
def run_migrations_online():
connectable = create_async_engine(config.get_main_option("sqlalchemy.url"))
async def do_run():
async with connectable.connect() as connection:
await connection.run_sync(do_migrations)
def do_migrations(connection):
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()
asyncio.run(do_run())
run_migrations_online()
```
### Step 2: Create Migrations
```bash
# Auto-generate from model changes
alembic revision --autogenerate -m "add projects table"
# Create empty migration (for data migrations)
alembic revision -m "backfill user roles"
```
```python
# alembic/versions/001_add_projects.py — Generated migration
def upgrade():
op.create_table('projects',
sa.Column('id', sa.String(36), primary_key=True),
sa.Column('name', sa.String(100), nullable=False),
sa.Column('owner_id', sa.String(36), sa.ForeignKey('users.id')),
sa.Column('created_at', sa.DateTime, server_default=sa.func.now()),
)
op.create_index('ix_projects_owner_id', 'projects', ['owner_id'])
def downgrade():
op.drop_index('ix_projects_owner_id')
op.drop_table('projects')
```
### Step 3: Data Migrations
```python
# alembic/versions/002_backfill_roles.py — Data migration
from alembic import op
import sqlalchemy as sa
def upgrade():
# Add column
op.add_column('users', sa.Column('role', sa.String(20), server_default='member'))
# Backfill existing rows
conn = op.get_bind()
conn.execute(sa.text("UPDATE users SET role = 'admin' WHERE email LIKE '%@mycompany.com'"))
def downgrade():
op.drop_column('users', 'role')
```
### Step 4: Commands
```bash
alembic upgrade head # apply all pending migrations
alembic downgrade -1 # rollback one migration
alembic history # show migration history
alembic current # show current revision
alembic upgrade +1 # apply next migration only
```
## Guidelines
- Always review autogenerated migrations — they may miss renames (detected as drop+create).
- Run migrations in CI before deploying — catch schema issues early.
- Data migrations should be idempotent — safe to run multiple times.
- Use `op.batch_alter_table()` for SQLite (which doesn't support ALTER TABLE well).
- Never edit applied migrations — create new ones instead.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.