“数据库迁移助手 - Schema 对比、迁移脚本生成”

— description from SKILL.md by laolaoshiren
MITAuto-check passedDatabases

Install DB Migrator

skills CLI
$ npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install laolaoshiren/claude-code-skills-zh db-migrator --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/db-migrator .claude/skills/db-migrator && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
db-migrator
GitHub stars
880
Token cost
~677 tokens
SKILL.md length
96 words
Files
1
Skills in repo
19
Repo updated
First seen
Licence
MIT

At a glance

  • SKILL.md covers 触发条件, 工作流程, 迁移模板 and 回滚策略, plus 1 more section
  • Calls npx and rails

About this skill

DB Migrator is a skill in laolaoshiren/claude-code-skills-zh (880 stars). Its SKILL.md is about 677 tokens. Licence: MIT.

What it can do on your machine

Read from SKILL.md and the folder at commit 633f21c. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • npx
    • rails

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use npx, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

DB Migrator loads about 677 tokens when it runs. Until then it costs about 10 tokens; SKILL.md has 96 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~10
When it runs · the whole SKILL.md, loaded when a task matches
~677

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from laolaoshiren/claude-code-skills-zh at commit 633f21c, republished under its MIT licence (© laolaoshiren). 96 words, ~677 tokens.

Download SKILL.mdSave it as .claude/skills/db-migrator/SKILL.md (or your agent's skills folder).
name
db-migrator
description
数据库迁移助手 - Schema 对比、迁移脚本生成

数据库迁移助手

触发条件

当用户要求数据库迁移、生成 migration、schema 变更、数据库升级时激活此技能。

工作流程

第 1 步:识别框架

扫描项目文件,判断使用的 ORM/迁移框架:

  • alembic.ini / alembic/ → Alembic
  • prisma/schema.prisma → Prisma
  • pom.xml 含 flyway → Flyway
  • manage.py + settings.py → Django
  • Gemfile + db/migrate/ → Rails
第 2 步:分析 Schema 变更
  • 对比 models 定义与现有迁移历史
  • 识别新增/修改/删除的表和字段
  • 检测索引、约束、外键变更
第 3 步:生成迁移脚本

根据框架生成对应的迁移文件,并同时生成回滚脚本。

第 4 步:风险评估
  • 大表 DDL 变更(锁表风险)
  • 数据迁移需求
  • 向后兼容性

迁移模板

Alembic (Python)
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)
sql
-- 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)
-- 逆向操作
Prisma (Node.js)
prisma
// schema.prisma 变更
model User {
  id    Int     @id @default(autoincrement())
  name  String
  email String? @unique  // 新增字段
}
bash
# 默认仅生成迁移,不执行数据库变更
npx prisma migrate dev --name add-email-to-users --create-only

检查生成的 SQL、连接目标和备份后,再由用户确认执行:

bash
# 开发环境应用迁移
npx prisma migrate dev

# 生产环境应用已审核并提交的迁移
npx prisma migrate deploy
Django (Python)
python
# users/migrations/0002_add_email.py
from django.db import migrations, models

class Migration(migrations.Migration):
    dependencies = [('users', '0001_initial')]

    operations = [
        migrations.AddField(
            model_name='user',
            name='email',
            field=models.EmailField(unique=True, null=True),
        ),
    ]

unique=True 已由 Django 生成唯一约束和对应索引,不要再创建重复索引。

Rails (Ruby)
ruby
# db/migrate/20260617_add_email_to_users.rb
class AddEmailToUsers < ActiveRecord::Migration[7.0]
  def change
    add_column :users, :email, :string
    add_index :users, :email, unique: true
  end
end
bash
rails db:migrate         # 执行迁移
rails db:rollback        # 回滚上一次
rails db:rollback STEP=3 # 回滚最近 3 次

回滚策略

场景策略
新增列直接移除该列
删除列无法自动回滚,需提前备份数据
修改列类型反向修改为原类型,注意数据丢失风险
新增表移除该表
数据迁移编写反向迁移脚本,保留原始数据快照
大表变更使用在线 DDL 工具避免锁表

注意事项

  • 默认只生成和审查迁移;执行前确认环境、数据库连接、备份和维护窗口
  • 框架支持可逆迁移时提供 downgrade;不支持时明确恢复快照或前向修复方案
  • 大表变更需考虑在线 DDL,避免长时间锁表
  • 数据迁移与 schema 变更分开处理
  • 迁移应由框架记录版本并安全重试,不要假设版本迁移可以任意重复执行
  • 在 staging 环境验证后再应用到生产环境
  • 涉及删除列/表的变更,确保应用代码已先移除相关引用

© laolaoshiren, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in skills/db-migrator of laolaoshiren/claude-code-skills-zh.

Open the folder on GitHubat commit 633f21c

Compare with similar skills

DB Migrator next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

DB Migrator compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
DB Migrator this skilllaolaoshiren/claude-code-skills-zh880—~677Automated safety check: PassMIT
Database Migrationsaffaan-m/ECC277k4 repos~3kAutomated safety check: PassMIT
Database Migrationsaffaan-m/ECC277k3 repos~1.9kAutomated safety check: PassMIT
Database Migrationsaffaan-m/ECC277k1 repos~2.4kAutomated safety check: PassMIT
Safe Database Migration Patternsaffaan-m/ECC276k—~3.3kAutomated safety check: PassMIT
Database Migrationsaffaan-m/ECC276k—~335Automated safety check: PassMIT

Similar skills

  • Safe, reversible database migration patterns: forward-only production changes, expand-contract zero-downtime renames, concurrent indexes, batched backfills, and per-tool workflows for PostgreSQL…

    277k GitHub starsUsed in 4 repos~3k tokens
    DatabasesAuto-check passed
  • 数据库迁移最佳实践,涵盖模式变更、数据迁移、回滚以及零停机部署,适用于PostgreSQL、MySQL及常用ORM(Prisma、Drizzle、Django、TypeORM、golang-migrate)。

    277k GitHub starsUsed in 3 repos~1.9k tokens
    DatabasesAuto-check passed
  • Şema değişiklikleri, veri migration'ları, rollback'ler ve PostgreSQL, MySQL ve yaygın ORM'ler (Prisma, Drizzle, Django, TypeORM, golang-migrate) arasında sıfır kesinti deployment'ları için…

    277k GitHub starsUsed in 1 repo~2.4k tokens
    DatabasesAuto-check passed
  • Rules and examples for safe, reversible schema changes in production: zero-downtime column and index changes, large data backfills and ORM migration workflows.

    276k GitHub stars~3.3k tokensUpdated yesterday
    DatabasesAuto-check passed
  • PostgreSQL、MySQL、一般的なORM(Prisma、Drizzle、Kysely、Django、TypeORM、golang-migrate)全体のスキーマ変更、データマイグレーション、ロールバック、ゼロダウンタイムデプロイメントのためのデータベースマイグレーションベストプラクティス。

    276k GitHub stars~335 tokensUpdated yesterday
    DatabasesAuto-check passed
  • Migrate

    softspark/ai-toolkit

    Run/create DB migrations (Alembic, Prisma, Laravel, Django, Flyway, Drizzle); checks backup.

    179 GitHub stars~1.3k tokensUpdated 2 days ago
    DatabasesAuto-check: notes

More from laolaoshiren/claude-code-skills-zh

All 19 skills in this repo
  • API Tester

    laolaoshiren/claude-code-skills-zh

    依据真实 OpenAPI、路由实现和现有测试生成并验证 API 测试。用于用户要求测试接口、补集成测试、验证 API 契约、生成回归用例或排查接口兼容性时;区分“生成测试”和“执行请求”的授权,不猜测状态码、响应结构或 SLA,不在未确认环境中发送写请求。

    880 GitHub stars~614 tokensUpdated 6 days ago
    Auto-check passed
  • Dep Auditor

    laolaoshiren/claude-code-skills-zh

    审计 Node.js、Python、Go、Rust、JVM、Ruby 项目的依赖漏洞、版本健康度与许可证事实;当用户要求检查 package.json、lockfile、requirements、go.mod、Cargo.toml、pom.xml、Gemfile.lock,或生成不改依赖的中文审计报告时使用

    880 GitHub stars~895 tokensUpdated 6 days ago
    Auto-check passed
  • Eslint Fix

    laolaoshiren/claude-code-skills-zh

    安全诊断并修复 ESLint error、warning 和配置兼容问题。用于用户要求运行 lint、解释 ESLint 报错、限定范围自动修复或迁移 ESLint 配置时;优先使用项目锁定的包管理器与版本,先预检再修改,不自动下载最新版或批量改写无关源码。

    880 GitHub stars~436 tokensUpdated 6 days ago
    Auto-check passed
  • Git Workflow

    laolaoshiren/claude-code-skills-zh

    安全处理 Git 状态检查、提交信息、commit、分支、push、PR 和 rebase。用于用户要求检查改动、生成或创建提交、管理分支、推送、发起 PR 或整理历史时;严格区分每个动作的授权,并保护工作树中已有和无关的修改。

    880 GitHub stars~513 tokensUpdated 6 days ago
    Auto-check passed
  • GitHub Actions Gen

    laolaoshiren/claude-code-skills-zh

    分析真实项目并生成或修订安全、可验证的 GitHub Actions workflow;当用户要求创建 CI、测试矩阵、构建、Release、部署、缓存、Secrets、OIDC、PR 自动化或排查 workflow 配置时使用

    880 GitHub stars~1.1k tokensUpdated 6 days ago
    Auto-check: notes
  • Skill Curator

    laolaoshiren/claude-code-skills-zh

    中文 Skill 收录评估器。用于核验 GitHub 上的 Claude Code、Codex、Agent Skills、Plugin、MCP、CLI 或 Agent 工作流是否值得加入精选列表;检查真实资产、安装方式、活跃度、重复项和安全边界,并生成分类、中文描述与可追溯证据。

    880 GitHub stars~756 tokensUpdated 6 days ago
    Auto-check passed

Works with

Questions about DB Migrator

How do I install DB Migrator in Claude Code?

Run `npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a claude-code`. Or copy the skill folder (skills/db-migrator in laolaoshiren/claude-code-skills-zh) into .claude/skills/db-migrator in your project. Claude Code loads it when a task matches its description.

How do I install DB Migrator in Codex?

Run `npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a codex`. Or copy the skill folder (skills/db-migrator in laolaoshiren/claude-code-skills-zh) into .agents/skills/db-migrator in your project. Codex loads it when a task matches its description.

Can I use DB Migrator in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/db-migrator, .gemini/skills/db-migrator, .github/skills/db-migrator and .opencode/skills/db-migrator in your project.

What does DB Migrator need to run?

Going by SKILL.md and its folder, DB Migrator needs the command-line tools its instructions call (npx and rails).

Does DB Migrator access the network?

SKILL.md contains no URLs. Its commands use npx, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is DB Migrator safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does DB Migrator use?

DB Migrator is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does DB Migrator use?

About 677 tokens (SKILL.md is roughly 2.7k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to DB Migrator?

Skills that share tags, products or a category with DB Migrator: Database Migrations (affaan-m/ECC, 277k stars), Database Migrations (affaan-m/ECC, 277k stars), Database Migrations (affaan-m/ECC, 277k stars) and Safe Database Migration Patterns (affaan-m/ECC, 276k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains DB Migrator?

laolaoshiren (a GitHub user) maintains it in laolaoshiren/claude-code-skills-zh, which has 880 GitHub stars. The repository holds 19 skills in this directory. The repository was last updated on October 5, 2026.

Source: laolaoshiren/claude-code-skills-zh on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.