Database Migrations
affaan-m/ECC
Safe, reversible database migration patterns: forward-only production changes, expand-contract zero-downtime renames, concurrent indexes, batched backfills, and per-tool workflows for PostgreSQL…
“数据库迁移助手 - Schema 对比、迁移脚本生成”
$ npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh db-migrator --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
$ 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-srcUse ~/.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/
Install the "db-migrator" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/db-migrator into .claude/skills/db-migrator/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "db-migrator", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$skill-installer install https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/db-migratorType this inside Codex. $skill-installer <name> installs a curated skill from openai/skills. The installer writes to $CODEX_HOME/skills (default ~/.codex/skills). Restart Codex if the skill does not show up.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh db-migrator --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .agents/skills && cp -r skills-src/skills/db-migrator .agents/skills/db-migrator && rm -rf skills-srcUse ~/.agents/skills/ instead of .agents/skills for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "db-migrator" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/db-migrator into .agents/skills/db-migrator/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "db-migrator", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh db-migrator --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .cursor/skills && cp -r skills-src/skills/db-migrator .cursor/skills/db-migrator && rm -rf skills-srcUse ~/.cursor/skills/ instead of .cursor/skills for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "db-migrator" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/db-migrator into .cursor/skills/db-migrator/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "db-migrator", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gemini skills install https://github.com/laolaoshiren/claude-code-skills-zh.git --path skills/db-migrator--scope user (default) or --scope workspace; --path is the subfolder of the repo that holds the skill; --consent skips the security confirmation prompt.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh db-migrator --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .gemini/skills && cp -r skills-src/skills/db-migrator .gemini/skills/db-migrator && rm -rf skills-srcUse ~/.gemini/skills/ instead of .gemini/skills for a personal install, then run /skills reload.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "db-migrator" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/db-migrator into .gemini/skills/db-migrator/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "db-migrator", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install laolaoshiren/claude-code-skills-zh db-migratorInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .github/skills && cp -r skills-src/skills/db-migrator .github/skills/db-migrator && rm -rf skills-srcUse ~/.copilot/skills/ instead of .github/skills for a personal install. Commit .github/skills so cloud agent and code review can use it.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "db-migrator" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/db-migrator into .github/skills/db-migrator/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "db-migrator", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add laolaoshiren/claude-code-skills-zh --skill db-migrator -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install laolaoshiren/claude-code-skills-zh db-migrator --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
$ git clone --depth 1 https://github.com/laolaoshiren/claude-code-skills-zh.git skills-src && mkdir -p .opencode/skills && cp -r skills-src/skills/db-migrator .opencode/skills/db-migrator && rm -rf skills-srcUse ~/.config/opencode/skills/ instead of .opencode/skills for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "db-migrator" agent skill from https://github.com/laolaoshiren/claude-code-skills-zh/tree/main/skills/db-migrator into .opencode/skills/db-migrator/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "db-migrator", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
db-migratorDB Migrator is a skill in laolaoshiren/claude-code-skills-zh (880 stars). Its SKILL.md is about 677 tokens. Licence: MIT.
Read from SKILL.md and the folder at commit 633f21c. It shows what the files ask for, not the result of running them.
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.
Shell commands in SKILL.md call:
npxrailsFrom the folder's file list and the shell code blocks in SKILL.md.
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.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
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.
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.
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.
The full file from laolaoshiren/claude-code-skills-zh at commit 633f21c, republished under its MIT licence (© laolaoshiren). 96 words, ~677 tokens.
.claude/skills/db-migrator/SKILL.md (or your agent's skills folder).当用户要求数据库迁移、生成 migration、schema 变更、数据库升级时激活此技能。
扫描项目文件,判断使用的 ORM/迁移框架:
alembic.ini / alembic/ → Alembicprisma/schema.prisma → Prismapom.xml 含 flyway → Flywaymanage.py + settings.py → DjangoGemfile + db/migrate/ → Rails根据框架生成对应的迁移文件,并同时生成回滚脚本。
"""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')-- 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)
-- 逆向操作// schema.prisma 变更
model User {
id Int @id @default(autoincrement())
name String
email String? @unique // 新增字段
}# 默认仅生成迁移,不执行数据库变更
npx prisma migrate dev --name add-email-to-users --create-only检查生成的 SQL、连接目标和备份后,再由用户确认执行:
# 开发环境应用迁移
npx prisma migrate dev
# 生产环境应用已审核并提交的迁移
npx prisma migrate deploy# 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 生成唯一约束和对应索引,不要再创建重复索引。
# 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
endrails db:migrate # 执行迁移
rails db:rollback # 回滚上一次
rails db:rollback STEP=3 # 回滚最近 3 次| 场景 | 策略 |
|---|---|
| 新增列 | 直接移除该列 |
| 删除列 | 无法自动回滚,需提前备份数据 |
| 修改列类型 | 反向修改为原类型,注意数据丢失风险 |
| 新增表 | 移除该表 |
| 数据迁移 | 编写反向迁移脚本,保留原始数据快照 |
| 大表变更 | 使用在线 DDL 工具避免锁表 |
© laolaoshiren, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
Just SKILL.md in skills/db-migrator of laolaoshiren/claude-code-skills-zh.
Open the folder on GitHubat commit 633f21c
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.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| DB Migrator this skilllaolaoshiren/claude-code-skills-zh | 880 | — | ~677 | Automated safety check: Pass | MIT | |
| Database Migrationsaffaan-m/ECC | 277k | 4 repos | ~3k | Automated safety check: Pass | MIT | |
| Database Migrationsaffaan-m/ECC | 277k | 3 repos | ~1.9k | Automated safety check: Pass | MIT | |
| Database Migrationsaffaan-m/ECC | 277k | 1 repos | ~2.4k | Automated safety check: Pass | MIT | |
| Safe Database Migration Patternsaffaan-m/ECC | 276k | — | ~3.3k | Automated safety check: Pass | MIT | |
| Database Migrationsaffaan-m/ECC | 276k | — | ~335 | Automated safety check: Pass | MIT |
affaan-m/ECC
Safe, reversible database migration patterns: forward-only production changes, expand-contract zero-downtime renames, concurrent indexes, batched backfills, and per-tool workflows for PostgreSQL…
affaan-m/ECC
数据库迁移最佳实践,涵盖模式变更、数据迁移、回滚以及零停机部署,适用于PostgreSQL、MySQL及常用ORM(Prisma、Drizzle、Django、TypeORM、golang-migrate)。
affaan-m/ECC
Ş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…
affaan-m/ECC
Rules and examples for safe, reversible schema changes in production: zero-downtime column and index changes, large data backfills and ORM migration workflows.
affaan-m/ECC
PostgreSQL、MySQL、一般的なORM(Prisma、Drizzle、Kysely、Django、TypeORM、golang-migrate)全体のスキーマ変更、データマイグレーション、ロールバック、ゼロダウンタイムデプロイメントのためのデータベースマイグレーションベストプラクティス。
softspark/ai-toolkit
Run/create DB migrations (Alembic, Prisma, Laravel, Django, Flyway, Drizzle); checks backup.
laolaoshiren/claude-code-skills-zh
依据真实 OpenAPI、路由实现和现有测试生成并验证 API 测试。用于用户要求测试接口、补集成测试、验证 API 契约、生成回归用例或排查接口兼容性时;区分“生成测试”和“执行请求”的授权,不猜测状态码、响应结构或 SLA,不在未确认环境中发送写请求。
laolaoshiren/claude-code-skills-zh
审计 Node.js、Python、Go、Rust、JVM、Ruby 项目的依赖漏洞、版本健康度与许可证事实;当用户要求检查 package.json、lockfile、requirements、go.mod、Cargo.toml、pom.xml、Gemfile.lock,或生成不改依赖的中文审计报告时使用
laolaoshiren/claude-code-skills-zh
安全诊断并修复 ESLint error、warning 和配置兼容问题。用于用户要求运行 lint、解释 ESLint 报错、限定范围自动修复或迁移 ESLint 配置时;优先使用项目锁定的包管理器与版本,先预检再修改,不自动下载最新版或批量改写无关源码。
laolaoshiren/claude-code-skills-zh
安全处理 Git 状态检查、提交信息、commit、分支、push、PR 和 rebase。用于用户要求检查改动、生成或创建提交、管理分支、推送、发起 PR 或整理历史时;严格区分每个动作的授权,并保护工作树中已有和无关的修改。
laolaoshiren/claude-code-skills-zh
分析真实项目并生成或修订安全、可验证的 GitHub Actions workflow;当用户要求创建 CI、测试矩阵、构建、Release、部署、缓存、Secrets、OIDC、PR 自动化或排查 workflow 配置时使用
laolaoshiren/claude-code-skills-zh
中文 Skill 收录评估器。用于核验 GitHub 上的 Claude Code、Codex、Agent Skills、Plugin、MCP、CLI 或 Agent 工作流是否值得加入精选列表;检查真实资产、安装方式、活跃度、重复项和安全边界,并生成分类、中文描述与可追溯证据。
Categories
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.
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.
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.
Going by SKILL.md and its folder, DB Migrator needs the command-line tools its instructions call (npx and rails).
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.
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.
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.
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.
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.
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.