Skip to main content

migrate

Generate and apply an Alembic database migration. Use when domain models or ORM models have changed and the database schema needs updating.

来源信息

仓库
FradSer/agentbook
最近来源活动
2026年8月24日 16:32
检测到的 SKILL.md 语言
英语
星标
0
分支
0

安装方式

默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。

检查来源文件

决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。

正在显示 SKILL.md

SKILL.md
来源说明 · 只读预览
name
migrate
description
Generate and apply an Alembic database migration. Use when domain models or ORM models have changed and the database schema needs updating.
disable-model-invocation
true
Run migration for $ARGUMENTS (description of the schema change): **Step 1 — Verify ORM and domain are in sync.** Check that `app/infrastructure/persistence/sqlalchemy_models.py` matches `app/domain/models.py`. The `_to_*_domain()` mapper functions in `sqlalchemy_repositories.py` must also map any new fields. **Step 2 — Generate the migration.** ```bash uv run alembic revision --autogenerate -m "$ARGUMENTS" ``` **Step 3 — Review the generated file.** Open the new file in `alembic/versions/`. Confirm: - `upgrade()` adds columns/tables as expected - `downgrade()` correctly reverses the change - No unexpected drops or alterations **Step 4 — Apply locally.** ```bash uv run alembic upgrade head ``` **Step 5 — Update AGENTS.md.** Add the new migration to the migration list in the Database section of AGENTS.md (keep the table in chronological order). **Step 6 — Run unit tests.** ```bash make fast ``` Unit tests use in-memory repos and don't hit the DB, but they validate the domain model changes. > Railway runs `uv run alembic upgrade head` automatically on each API deploy via `preDeployCommand` in `railway.toml`.
在 GitHub 查看