跳到正文
cccskills
免费在 GitHub 公开

database-migrations

Database migration best practices for schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs (Prisma, Drizzle, Kysely, Django, TypeORM, golang-migrate).

中文简介正在准备中。当前显示原文说明。

集成工具PostgreSQLMySQL
查看安装方法

包含的文件(2)

  • SKILL.md5.0 KB
  • REFERENCE.md7.4 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

/supergraph:database-migrations

Safe, reversible database schema changes for production systems.

Announce: "🗄️ /supergraph:database-migrations — checking blast radius and migration safety..."

When to Activate

  • Creating or altering database tables
  • Adding/removing columns or indexes
  • Running data migrations (backfill, transform)
  • Planning zero-downtime schema changes
  • Setting up migration tooling for a new project

Steps

1. Check blast radius (MANDATORY before writing any migration)

Use CBM_PROJECT: search_graph schema/model symbols, trace_path inbound and data-flow, then validated dependencies, hubs, and test-gaps recipes. Schema changes to hub tables (e.g. users, orders) ripple through repositories, queries, services. If blast radius > 20 files → STOP and discuss with user.

Serena symbol-level impact (optional):

mcp__serena__find_referencing_symbols(symbol=<column_or_model_name>)

Finds ORM field references that graph tools see only at file level — e.g. a Prisma field rename that query_graph sees as "file touched" but Serena sees as "12 usages in service layer". Skip if Serena unavailable.

2. Choose migration pattern

Select the appropriate pattern from the sections below (PostgreSQL, Prisma, Drizzle, etc.) based on detected project type from .supergraph-env.

3. Write migration

Follow Migration Safety Checklist before writing SQL/ORM migration code.

4. Verify flows

After migration written: Use trace_path(project=CBM_PROJECT, mode="data_flow") and the dependencies recipe. Empty results are unavailable evidence requiring Serena/filesystem fallback, not invented flows. All data flows still intact? Application code updated to match schema?

5. Report

✅ /supergraph:database-migrations
- Pattern: [expand-contract | add-column | add-index | data-migration | ...]
- Blast radius: N files | Hub tables: [list/none]
- Safety checklist: PASS | BLOCKED (list issues)
- Next: /supergraph:tdd → /supergraph:fix → /supergraph:verify

Core Principles

  1. Every change is a migration — never alter production databases manually
  2. Migrations are forward-only in production — rollbacks use new forward migrations
  3. Schema and data migrations are separate — never mix DDL and DML in one migration
  4. Test migrations against production-sized data — a migration that works on 100 rows may lock on 10M
  5. Migrations are immutable once deployed — never edit a migration that has run in production

Migration Safety Checklist

Before applying any migration:

  • Migration has both UP and DOWN (or is explicitly marked irreversible)
  • No full table locks on large tables (use concurrent operations)
  • New columns have defaults or are nullable (never add NOT NULL without default)
  • Indexes created concurrently (not inline with CREATE TABLE for existing tables)
  • Data backfill is a separate migration from schema change
  • Tested against a copy of production data
  • Rollback plan documented

Full ORM examples (PostgreSQL, Prisma, Drizzle, Kysely, Django, golang-migrate): REFERENCE.md

Anti-Patterns

Anti-PatternWhy It FailsBetter Approach
Manual SQL in productionNo audit trail, unrepeatableAlways use migration files
Editing deployed migrationsCauses drift between environmentsCreate new migration instead
NOT NULL without defaultLocks table, rewrites all rowsAdd nullable, backfill, then add constraint
Inline index on large tableBlocks writes during buildCREATE INDEX CONCURRENTLY
Schema + data in one migrationHard to rollback, long transactionsSeparate migrations
Dropping column before removing codeApplication errors on missing columnRemove code first, drop column next deploy

Rules

  • ALWAYS check blast radius before writing any migration — hub table changes need user approval
  • NEVER alter production databases manually — every change goes through migration files
  • NEVER mix DDL and DML in one migration — separate schema changes from data migrations
  • NEVER add NOT NULL column without a default to existing tables — locks and rewrites all rows
  • ALWAYS create indexes with CONCURRENTLY on live tables
  • ALWAYS test against production-sized data before deploying
  • NEVER edit a migration that has already run in production — create a new one
  • Use expand-contract pattern for zero-downtime column renames and removals

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

analyze

免费

Risk analysis and approach selection before planning. Use when requirements are ambiguous, approaches vary, or work touches hub/bridge nodes. Skip for typo fixes.

中文简介正在准备中。当前显示原文说明。

datit309/supergraph212026年10月18日 更新

Proactive architecture review — explore codebase structure, generate a self-contained HTML report with Mermaid diagrams and candidate improvements, then grill the findings. Use when planning a large refactor, onboarding to an unfamiliar codebase, or before a major architectural change.

中文简介正在准备中。当前显示原文说明。

datit309/supergraph212026年10月18日 更新

Autonomous human-like browser control and professional QA/QC testing. Powered by agent-browser (Rust native CDP, zero Playwright) with ISTQB test matrix generation, automated testcase execution, console/network error tracing, and defect reporting.

中文简介正在准备中。当前显示原文说明。

datit309/supergraph212026年10月18日 更新

caveman

免费

Persistent token-compression mode (~75% reduction) — now always-on by default. Strips filler while keeping code exact.

中文简介正在准备中。当前显示原文说明。

datit309/supergraph212026年10月18日 更新

Anti-slop frontend skill for landing pages, portfolios, and redesigns. The agent reads the brief, infers the right design direction, and ships interfaces that do not look templated. Real design systems when applicable, audit-first on redesigns, strict pre-flight check.

中文简介正在准备中。当前显示原文说明。

datit309/supergraph212026年10月18日 更新

diagnose

免费

Structured 6-phase debugging. Build feedback loop first, reproduce deterministically, hypothesize with ranked falsifiable theories, instrument one variable at a time, fix with regression test, cleanup. Use when a bug exists, tests fail unexpectedly, or behavior is wrong and cause is unknown.

中文简介正在准备中。当前显示原文说明。

datit309/supergraph212026年10月18日 更新

查看 datit309 的全部技能

报告此技能的问题