Database Migration
Use when running, rolling back, or generating Alembic database migrations. Trigger on: "run migrations", "create migration", "rollback migration", "alembic", or any task that modifies the database schema.
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-14
- Stars
- ★ 25
- Forks
- 9
01 前言 Front Matter
- name
- Database Migration
- owner
- automation-engineer
- status
- active
- version
- 1.0.0
- description
- Use when running, rolling back, or generating Alembic database migrations. Trigger on: "run migrations", "create migration", "rollback migration", "alembic", or any task that modifies the database schema.
03 SKILL.md 正文
Overview
This skill guides the AI through safe database migration workflows using Alembic. It ensures migrations are generated correctly, reviewed before running, and rolled back cleanly if needed.
Generate a Migration
Purpose: Create a new migration file from ORM model changes. Trigger: ORM model was modified and schema needs to be updated.
Steps:
- Verify the virtual environment is active:
which pythonshould point to.venv/ - Run autogenerate:
alembic revision --autogenerate -m "describe the change" - Review the generated file in
alembic/versions/- autogenerate is not always correct - Check for: missing
op.create_index, incorrect column types, missingnullablechanges - Report the generated file path and a summary of what it will do
Output: Path to the new migration file + summary of schema changes.
Run Migrations
Purpose: Apply pending migrations to the database. Trigger: Deployment, local setup after clone, or after generating a new migration.
Steps:
- Confirm
DATABASE_URLis set in environment:echo $DATABASE_URL - Show pending migrations:
alembic history --indicate-current - Run:
alembic upgrade head - Verify:
alembic currentshould show the latest revision
Output: Confirmation of which revision is now current.
Rollback a Migration
Purpose: Undo the most recent migration. Trigger: Migration caused issues, need to revert schema change.
Steps:
- Show current state:
alembic current - Roll back one step:
alembic downgrade -1 - Verify:
alembic currentshould show the previous revision - ⚠️ Warn if data loss is possible (e.g., dropping a column)
Output: Confirmation of rolled-back revision + any data loss warnings.
04 同仓库更多 Skills
i18n-layout
Text layout and encoding guidance: character encoding (UTF-8, legacy Korean code pages, BOM hazards), line endings, RTL/bidi handling, and script-specific font selection (Hangul focus). Use when: encoding is corrupted or mojibake appears, an RTL locale must render correctly, fonts must be chosen for a script, or CRLF/BOM issues surface.
i18n-layout
Text layout and encoding guidance: character encoding (UTF-8, legacy Korean code pages, BOM hazards), line endings, RTL/bidi handling, and script-specific font selection (Hangul focus). Use when: encoding is corrupted or mojibake appears, an RTL locale must render correctly, fonts must be chosen for a script, or CRLF/BOM issues surface.
i18n-layout
Text layout and encoding guidance: character encoding (UTF-8, legacy Korean code pages, BOM hazards), line endings, RTL/bidi handling, and script-specific font selection (Hangul focus). Use when: encoding is corrupted or mojibake appears, an RTL locale must render correctly, fonts must be chosen for a script, or CRLF/BOM issues surface.
i18n-layout
Text layout and encoding guidance: character encoding (UTF-8, legacy Korean code pages, BOM hazards), line endings, RTL/bidi handling, and script-specific font selection (Hangul focus). Use when: encoding is corrupted or mojibake appears, an RTL locale must render correctly, fonts must be chosen for a script, or CRLF/BOM issues surface.
i18n-layout
Text layout and encoding guidance: character encoding (UTF-8, legacy Korean code pages, BOM hazards), line endings, RTL/bidi handling, and script-specific font selection (Hangul focus). Use when: encoding is corrupted or mojibake appears, an RTL locale must render correctly, fonts must be chosen for a script, or CRLF/BOM issues surface.
i18n-layout
Text layout and encoding guidance: character encoding (UTF-8, legacy Korean code pages, BOM hazards), line endings, RTL/bidi handling, and script-specific font selection (Hangul focus). Use when: encoding is corrupted or mojibake appears, an RTL locale must render correctly, fonts must be chosen for a script, or CRLF/BOM issues surface.