数据库 Schema Diff 技能:核对 PostgreSQL 结构漂移
EnglishClaude Code 安装步骤
- 从 GitHub 固定提交获取完整的 `plugins/database/database-diff-tool/skills/comparing-database-schemas` 目录。
- 复制到目标项目的 `.claude/skills/`,确认 `.claude/skills/comparing-database-schemas/SKILL.md`,再从项目根目录启动 Claude Code,输入 `/comparing-database-schemas`。
中文摘要
对照两份数据库定义,找出字段、索引与约束变化。用 Claude Code 输出可逐项复核的 PostgreSQL 差异清单。
SKILL.md 中文导读
可复现示例
准备两个本地测试库。在基准库的 orders 表建立索引 orders_created_at_idx,并令 status 默认值为 'pending'。另一库只将该字段默认值设为 'draft'。用 pg_dump --schema-only --no-owner --no-privileges 分别导出后比较。工作步骤
- 按对象名把表、字段、默认值、索引和约束对应起来。忽略文件顺序等无关差异。
- 为每项差异标明源库、目标库、对象及其定义。确认是否为预期变更,再决定是否起草迁移。
验收方法
报告指出目标库缺失 orders_created_at_idx,且 orders.status 的默认值与基准不同。结果可在两份 DDL 中逐项复核。
GitHub 原文 · 更新日期
适用环境
准备两份测试数据库的 schema-only 导出,或两份可信的 SQL DDL。对比时保持 PostgreSQL 客户端版本一致。
常见问题
发现缺失索引就可以执行迁移吗?
先核对现有迁移记录并在一次性副本上验证,确认目标版本和影响后再安排生产变更。
相关指南
相关推荐
groq-install-auth 技能
jeremylongshore/claude-code-plugins-plus-skills
anima-common-errors 技能
jeremylongshore/claude-code-plugins-plus-skills
apple-notes-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
castai-hello-world 技能
jeremylongshore/claude-code-plugins-plus-skills
cohere-local-dev-loop 技能
jeremylongshore/claude-code-plugins-plus-skills
figma-security-basics 技能
jeremylongshore/claude-code-plugins-plus-skills