
Db Migrator
Handles the tedious work of comparing database schemas and generating migration scripts across multiple frameworks. You point it at your models or existing database structure, it identifies what changed (new tables, modified columns, deletions), then spits out proper migration files with both upgrade and downgrade paths. Supports the usual suspects like Alembic, Prisma, Django, Rails, and Flyway. The real value is it reminds you about things you'd forget at 2am, like creating indexes alongside columns or splitting data migrations from schema changes. It won't magically solve your online DDL problems on a billion row table, but it saves you from writing boilerplate migration code by hand.
- GitHub stars
- 328
- last updated
- May 13, 2026
Install
$ npx -y skills add laolaoshiren/claude-code-skills-zh --skill db-migrator --agent claude-codeInstalls into .claude/skills of the current project.
Files
数据库迁移助手
触发条件
当用户要求数据库迁移、生成 migration、schema 变更、数据库升级时激活此技能。
工作流程
第 1 步:识别框架
扫描项目文件,判断使用的 ORM/迁移框架:
alembic.ini/alembic/→ Alembicprisma/schema.prisma→ Prismapom.xml含 flyway → Flywaymanage.py+settings.py→ DjangoGemfile+db/migrate/→ Rails
第 2 步:分析 Schema 变更
- 对比 models 定义与现有迁移历史
- 识别新增/修改/删除的表和字段
- 检测索引、约束、外键变更
第 3 步:生成迁移脚本
根据框架生成对应的迁移文件,并同时生成回滚脚本。
第 4 步:风险评估
- 大表 DDL 变更(锁表风险)
- 数据迁移需求
- 向后兼容性
迁移模板
Alembic (Python)
"""add email column to users
Revision ID: abc123
"""
from alembic import op
import sqlalchemy as sa
def upgrade():
op.add_column('users', sa.Column('email', sa.String(255), nullable=True))
op.create_index('ix_users_email', 'users', ['email'], unique=True)
def downgrade():
op.drop_index('ix_users_email')
op.drop_column('users', 'email')
Flyway (Java)
-- V2__add_email_to_users.sql
ALTER TABLE users ADD COLUMN email VARCHAR(255);
CREATE UNIQUE INDEX ix_users_email ON users(email);
-- 回滚脚本 (单独文件 U2__rollback_add_email.sql)
-- 逆向操作
Sponsors
Details
- Repository
- github.com/laolaoshiren/claude-code-skills-zh
- License
- MIT
- First seen
- Jun 11, 2026