alembic-migrate

Generate and apply Alembic migrations for async SQLAlchemy models on SQLite.

Updated May 22, 2026
One-click install
npx skills add https://github.com/WU-MAO-CHIA/AI_tset_platfrom --skill alembic-migrate-wu-mao-chia
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: alembic-migrate
Source: https://github.com/WU-MAO-CHIA/AI_tset_platfrom/tree/main/.opencode/skills/alembic-migrate
Command: npx skills add https://github.com/WU-MAO-CHIA/AI_tset_platfrom --skill alembic-migrate-wu-mao-chia

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires alembic, sqlalchemy, aiosqlite.

What problem does it solve? Changing database schema in the autotest backend requires hand-writing Alembic migrations that stay in sync with the async SQLAlchemy models, and mistakes like forgotten model imports, destructive autogenerated drops, or SQLite ALTER limitations can silently corrupt the schema or lose data. ## Core Features & Use Cases - Autogenerated Migrations: Runs alembic revision --autogenerate against the models in backend/src/models/ and guides review of the generated revision file. - SQLite-Specific Safeguards: Handles SQLite limitations such as batch_alter_table requirements, rename-as-drop+add pitfalls, and NOT NULL column backfill strategies. - Safe Apply and Rollback: Enforces pre-flight checks (alembic current, git status) and tests downgrade/upgrade cycles before committing. - Use Case: After adding a new column to a model in backend/src/models/, use this Skill to generate the migration, verify the operations, apply it to the local SQLite database, and confirm rollback works before committing both files together. ## Quick Start Ask the assistant to create and apply an Alembic migration for the model change you just made in backend/src/models/.

Frequently Asked Questions about alembic-migrate

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

FAQPage Schema
How do I create an Alembic migration for SQLAlchemy models?▼

Edit the model under backend/src/models/ first, ensure it is imported in alembic/env.py, then run alembic revision --autogenerate -m "summary" from the backend directory. Review the generated file in alembic/versions/ before applying it with alembic upgrade head.

Why does Alembic autogenerate produce an empty migration?▼

Autogenerate only sees models imported into the metadata module in alembic/env.py. If the new or changed model is not imported there, Alembic detects no differences and produces an empty migration. Import the model and regenerate.

Does Alembic support ALTER COLUMN on SQLite?▼

SQLite has limited ALTER COLUMN support, so Alembic uses the batch_alter_table pattern, which recreates the table with the new schema. Keep the autogenerated batch_alter_table operations rather than replacing them with plain alter_column calls.

How do I rename a column in Alembic without losing data?▼

Autogenerate treats a rename as a drop plus add, which loses existing data. Hand-edit the revision to use op.alter_column with the new_column_name parameter so the column is renamed in place and data is preserved.

When should I not create an Alembic migration?▼

Skip migrations for pure SELECT query changes with no schema impact, or when renaming a Python attribute that maps to the same underlying column name. This skill also assumes a SQLite dev database, so production PostgreSQL migrations need separate review.