pdlc-db-migrate

pdlc-db-migrate is a skill for Claude Code from kanfu-panda/pdlc-skills. It costs 11 tokens per session (1,948 once invoked), scanned A, original, MIT.

A database migration manager driven by database design documents. A migration is a versioned script that changes a database structure and can also undo that change.

In plain words
What is it for?
Use it to generate or compare migration scripts, check migration status, apply pending changes, and undo recent migrations in single-service or microservice projects.
Why use it?
It keeps database changes tied to an approved design and makes it easier to see what has run, apply pending changes, or roll back recent ones. It also prevents generating changes when the required design document is missing.

Skill for Claude Code

Written for Claude Code: allowed-tools in frontmatter.

Part of the pdlc plugin — 38 skills shipped together

Good fit Use it to generate or compare migration scripts, check migration status, apply pending changes, and undo recent migrations in single-service or microservice projects.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kanfu-panda/pdlc-skills/pdlc-db-migrate
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add kanfu-panda/pdlc-skills --skill pdlc-db-migrate
Clone the repo
git clone --depth 1 https://github.com/kanfu-panda/pdlc-skills

Made for: Claude Code.

Or install pdlc, the plugin that ships this one along with the rest of its 38 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pdlc-db-migrate

README.md
[![agentmods](https://agentmods.dev/badge/skills/kanfu-panda/pdlc-skills/pdlc-db-migrate/github.svg)](https://agentmods.dev/skills/kanfu-panda/pdlc-skills/pdlc-db-migrate)
Your own site
<a href="https://agentmods.dev/skills/kanfu-panda/pdlc-skills/pdlc-db-migrate"><img src="https://agentmods.dev/badge/skills/kanfu-panda/pdlc-skills/pdlc-db-migrate/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pdlc-db-migrate

Your own site · 80×15
<a href="https://agentmods.dev/skills/kanfu-panda/pdlc-skills/pdlc-db-migrate"><img src="https://agentmods.dev/badge/skills/kanfu-panda/pdlc-skills/pdlc-db-migrate.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 11 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,948 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00011 $0.01948
Opus 5 $0.00005 $0.00974
Sonnet 5 $0.00002 $0.00390
Haiku 4.5 $0.00001 $0.00195

Measured 11d ago against content hash 94ffc1c56f07, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

pdlc-db-migrate scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/pdlc-db-migrate/SKILL.md · 199 lines

How it starts

The opening of the file, as written. The whole thing — 199 lines — stays where its author put it; the contents beside it link to each section on GitHub.

数据库迁移管理

根据 db-design 文档管理数据库迁移脚本,支持生成、执行、回滚和状态查看。

子命令解析

$ARGUMENTS 中解析子命令和参数:

子命令 格式 说明
generate <描述> 根据 db-design 文档生成版本化迁移脚本(up + down)
status 查看迁移状态,列出已执行/待执行的迁移
up 执行所有待执行的迁移
down [N] 回滚最近 N 个迁移(默认 1)
diff <功能名> 对比 db-design 文档与现有迁移脚本,生成增量迁移

如果未提供子命令或子命令无法识别,输出以上帮助信息后停止。


PDLC 前置检查(仅 generate 和 diff 子命令)

当子命令为 generatediff 时执行:

  1. 从用户输入中提取功能名称关键词
  2. docs/02_design/database/ 目录下搜索包含该关键词的数据库设计文档
    • 匹配新格式:F<日期>-<编号>-*<关键词>*-db.md
    • 匹配旧格式:YYYYMMDD-*<关键词>*-db.md
    • 同时检查文件内容中是否包含该关键词
  3. 未找到 → 输出以下信息后立即停止,不继续执行
    ⛔ PDLC 守卫:未找到与「<功能名>」相关的数据库设计文档。
    迁移脚本必须基于已有的数据库设计。请先运行:
    👉 /pdlc-db-design <设计目标>
    
  4. 找到 → 提取功能ID(如 F20260326-090000),读取该设计文档内容,继续执行

迁移文件约定

目录结构

  • 微服务项目:backend/services/<service>/migrations/
  • 单服务项目:migrations/
  • 自动检测:如果存在 backend/services/ 目录,按微服务项目处理;否则按单服务项目处理

文件命名

  • UP 脚本:V<版本号>__<描述>.sql
  • DOWN 脚本(回滚):R<版本号>__<描述>.sql
  • 版本号格式:YYYYMMDD_HHMMSS(如 20260402_143052

文件头部注释

每个迁移文件必须包含以下头部注释:

-- ==============================================
-- 迁移脚本: V20260402_143052__create_users_table.sql
-- 功能ID: F20260402-090000
-- 描述: 创建用户表
-- 作者: <从 git config 获取>
-- 日期: 2026-04-02
-- ==============================================

子命令执行流程

generate <描述>

  1. 执行前置检查,读取 db-design 文档
  2. 读取 .claude/templates/pdlc/db-migrate-template.md 模板
  3. 生成版本号:使用当前时间戳 YYYYMMDD_HHMMSS
  4. 从 db-design 文档中提取 DDL 脚本和回滚脚本
  5. 生成 UP 迁移文件:V<版本号>__<描述>.sql
    • 包含头部注释
    • 包含 CREATE TABLE / ALTER TABLE / INSERT 等语句
    • 每条语句末尾添加分号
  6. 生成 DOWN 迁移文件:R<版本号>__<描述>.sql
    • 包含头部注释
    • 包含对应的回滚操作(DROP TABLE / ALTER TABLE DROP COLUMN 等)
    • 操作顺序与 UP 相反
  7. 更新迁移历史记录文件 migrations/migration_history.md
  8. 输出生成结果摘要

status

  1. 查找迁移目录下所有 V*.sql 文件

  2. 读取 migrations/migration_history.md(如不存在则提示无迁移记录)

  3. 输出迁移状态表格:

    📋 迁移状态
    
    | 版本号 | 描述 | 功能ID | 状态 | 执行时间 |
    |--------|------|--------|------|----------|
    | 20260402_143052 | 创建用户表 | F20260402-090000 | ✅ 已执行 | 2026-04-02 14:35 |
    | 20260402_150000 | 添加订单表 | F20260402-100000 | ⏳ 待执行 | - |
    
    已执行: 1 | 待执行: 1 | 总计: 2
    

Read the full file on GitHub · 199 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 199 lines · 11 tokens per session scan A 94ffc1c56f07

Subscribe to this mod's changes

pdlc-db-migrate is a skill published in the GitHub repository kanfu-panda/pdlc-skills (13 stars, last pushed yesterday), licensed MIT. It adds 11 tokens to every session and 1,948 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

postgres-database-migration

Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production data or shared databases. Trigger when user asks to: Test a schema migration before applying it to production Add, remove, or rename columns safely on a live table Change a column's data…

timescale/pg-aiguide · 220 tokens

setup-timescaledb-hypertables

Use this skill when creating database schemas or tables for Timescale, TimescaleDB, TigerData, or Tiger Cloud, especially for time-series, IoT, metrics, events, or log data. Use this to improve the performance of any insert-heavy table. Trigger when user asks to: Create or design SQL schemas/tables AND…

timescale/pg-aiguide · 219 tokens

design-postgis-tables

Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and performance patterns for location-based applications.

timescale/pg-aiguide · 31 tokens

migrate-postgres-tables-to-hypertables

Use this skill to migrate identified PostgreSQL tables to Timescale/TimescaleDB hypertables with optimal configuration and validation. Trigger when user asks to: Migrate or convert PostgreSQL tables to hypertables Execute hypertable migration with minimal downtime Plan blue-green migration for large tables Validate…

timescale/pg-aiguide · 181 tokens

pgvector-semantic-search

Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search. Trigger when user asks to: Store or search vector embeddings in PostgreSQL Set up semantic search, similarity search, or nearest neighbor search Create HNSW or IVFFlat indexes for vectors…

timescale/pg-aiguide · 190 tokens

find-hypertable-candidates

Use this skill to analyze an existing PostgreSQL database and identify which tables should be converted to Timescale/TimescaleDB hypertables. Trigger when user asks to: Analyze database tables for hypertable conversion potential Identify time-series or event tables in an existing schema Evaluate if a table would…

timescale/pg-aiguide · 184 tokens