一键导入
drizzle-sql-migration
Use when writing or applying Drizzle ORM database migrations — schema changes (DDL) and data fixes (DML custom migrations).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use when writing or applying Drizzle ORM database migrations — schema changes (DDL) and data fixes (DML custom migrations).
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | drizzle-sql-migration |
| description | Use when writing or applying Drizzle ORM database migrations — schema changes (DDL) and data fixes (DML custom migrations). |
| user-invocable | true |
| allowed-tools | ["Read","Bash","Grep","Glob","Edit","Write"] |
A focused guide for writing and applying Drizzle ORM database migrations, covering both schema changes (DDL) and data fixes (DML custom migrations).
drizzle/). Check drizzle.config.ts for the configured path..sql file with a timestamp-based name.__drizzle_migrations table in the database.npx drizzle-kit generate — diffs your schema file against the last snapshot and writes SQL automatically (for DDL/schema changes).npx drizzle-kit generate --custom — creates an empty .sql file for you to fill in (for DML/data fixes).Step by step:
drizzle.config.ts for the schema field.npx drizzle-kit generate
Drizzle diffs the current schema against its last snapshot and writes the SQL migration file.drizzle/ and verify the SQL is correct. Pay special attention to renames — Drizzle may generate a DROP COLUMN + ADD COLUMN instead of ALTER TABLE ... RENAME COLUMN. Fix if needed.npx drizzle-kit migrate
Step by step:
npx drizzle-kit generate --custom --name=describe-what-it-does
UPDATE users SET status = 'active' WHERE status IS NULL;
npx drizzle-kit migrate
BEGIN;
UPDATE accounts SET balance = balance * 1.05 WHERE tier = 'premium';
-- Verify row count before committing
COMMIT;
You cannot add a NOT NULL column to a table that already has rows without a default. Use a three-step approach:
NOT NULL (schema migration).Drizzle does not detect renames. When you rename a column in the schema file, drizzle-kit generate will produce a DROP COLUMN + ADD COLUMN, which destroys data.
Fix: edit the generated SQL and replace the DROP/ADD with:
ALTER TABLE "my_table" RENAME COLUMN "old_name" TO "new_name";
For tables with >100k rows, CREATE INDEX locks the table. Use a custom migration instead:
npx drizzle-kit generate --custom --name=add-index-concurrentlyCREATE INDEX CONCURRENTLY "idx_name" ON "my_table" ("column_name");
Note: CONCURRENTLY cannot run inside a transaction. Ensure your migration runner does not wrap this in a transaction block.Before applying a generated migration to anything beyond local dev — especially one touching a large or high-traffic table — dispatch the migration SQL to the data-engineer subagent for a safety pass. Ask it to check lock behavior and duration at production row counts, zero-downtime (expand/contract) compatibility with currently-running code, backfill strategy for any data change, and whether the rollback path is sound. Act on its findings before you run the migration; it reviews, it does not apply.
Agent({
subagent_type: "data-engineer",
description: "Migration safety review",
prompt: "Review this Drizzle migration before it is applied: <the generated SQL and the table's approximate row count if known>. Assess lock type and duration at production scale, zero-downtime compatibility with old code still running during rollout, backfill safety for any data change, and the rollback path. Return blocking risks first, then hardening suggestions, quoting the specific statement for each."
})
Research a work item, draft an implementation plan, and begin work after approval.
Guided one-shot install — discover installed plugins (or help install new ones), pick install scope, calibrate risk tolerance into a concrete allowlist + hooks, scaffold or merge CLAUDE.md, and sanity-check the result.
Finalize work — commit via /commit, push, and create PRs on feature branches.
Reviewer-side PR workflow — checks out the branch in a worktree, runs focus-area reviews plus a senior-engineering pass, optionally cross-checks against an autonomous reviewer, and posts inline findings only on explicit approval. Read-only — never edits, commits, or pushes.
Fetch PR review comments, classify by severity and confidence, and fix the selected subset.
Triage CVE and SBOM scanner output (Trivy, Grype, Snyk, Docker Scout, Dependabot) into a ranked, deduplicated action list.