/datumpin:alembic-migrationsfrom datumpin
Alembic migrations in a FastAPI/SQLAlchemy service - env.py, SQLite batch mode, container-only commands. Use when adding or reviewing a migration.
Ships in datumpin. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
database/
base.py # DeclarativeBase, isolated so env.py can import Base alone
models.py
engine.py # engine + SessionLocal, reads settings.database_url
migrate_and_seed.py
migrations/{env.py, script.py.mako, versions/}
alembic.ini
base.py keeps the circular import between engine.py and models.py out of env.py.
alembic.ini and env.pyalembic.ini leaves sqlalchemy.url = blank, with script_location = database/migrations and prepend_sys_path = .. env.py supplies the URL from settings:
from database.base import Base
from database import models # noqa: F401 — registers every model on Base.metadata
from config import settings # or `from settings import get_settings`
config.set_main_option("sqlalchemy.url", settings.database_url)
target_metadata = Base.metadata
Both run_migrations_online() and run_migrations_offline() pass render_as_batch=True. SQLite cannot ALTER TABLE to drop a column or change a constraint, and batch mode rebuilds the table to do it.
Alembic lives inside the container only (see docker-compose-conventions), with the instance's env file (see config-led-deployment):
docker compose --env-file .env.<app>-<instance>.dev -f docker-compose.dev.yml exec <service> alembic revision --autogenerate -m "short description"
Use run --rm <service> ... when the container is down. The new file lands in versions/, bind-mounted back to the host.
op.rename_table or op.alter_column(new_column_name=...) plus constraint renames, even when the table is empty everywhere. Autogenerate emits drop-and-create.add_column plus a backfill in the same revision.migrate_and_seed.py's run() calls alembic upgrade head first on container boot. It is idempotent, and it builds every table on an empty database. Seeding follows (see config-led-deployment).
Before a schema is deployed anywhere real, regenerate the initial migration in place as the design settles. Once it is live anywhere, migrate incrementally.
docker compose ... exec <service> alembic check reports no drift.alembic upgrade head succeeds on an empty DB and on a copy of the seeded DB.rename_table/alter_column and no drop_table/drop_column.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
31 skills in this plugin
/alignAlign - find and fix drift between code, tickets and plans. Use when a repo joins the workflow, direction changes, a milestone closes, or to clean the backlog./api-documentationDocumenting HTTP APIs - endpoint docstrings, router READMEs, docs/reference/api. Use when adding or editing a FastAPI route./boardBoard - sync the Gitea tickets, show the kanban, suggest the next ticket. Use at session start or when asked for the board, backlog or what to do next./change-readyChange ready - the checklist a change passes before it is opened as a PR. Use when finishing work, before a closing commit, or asked if it is ready.npx claudepluginhub jago971/dp-cli --plugin datumpin