drizzle-safe-migrations
БесплатноБез исполняемых скриптовНе проверенPlan safe Drizzle backfills, enum/check/default changes, constraint tightening, migration ordering, and rollback. Excludes other ORMs, query optimization, and…
от pedronauck★ 661 звезда на GitHubОб этом скилле
Drizzle Safe Migrations
Overview
Use this skill to run database migrations in a way that is auditable, deployment-safe, and consistent with Drizzle's migration model.
Core Rules
- Generate schema migrations with the existing project script and package manager;
bun run db:generatebelow is an example, not a required script name. - Never hand-edit generated schema migration files.
- Generate data backfills as custom migrations (
bun run db:generate -- --custom --name <name>) and edit only that custom SQL file. - Apply data normalization before tightening constraints.
- Keep one-off data fixes in migration history, not as hidden runtime logic, unless an emergency hotfix requires temporary mitigation.
Workflow
- Classify the change:
schema-only: only column/table/index/default changes.data+schema: old rows must be transformed before new constraints/defaults.
- For
data+schema, create custom migration first:bun run db:generate -- --custom --name <descriptive_name>- Add idempotent backfill SQL.
- Generate schema migration second:
bun run db:generate
- Verify migration ordering in
drizzle/meta/_journal.json:- backfill migration index must be lower than constraint-tightening migration index.
- Verify generated SQL and snapshots:
- backfill migration contains only intended data change.
- schema migration contains constraint/default/type changes.
- Run the owning migration suite against existing-data and fresh-install cases, plus required project gates. Reuse current evidence; unrelated backend suites are not an additional skill gate.
- Record material rollout risks and recovery steps when applicable:
- expected data transformations,
- lock-risk areas,
- rollback strategy.
Backfill Requirements
- Use restrictive
WHEREclauses. - Prefer idempotent updates (
UPDATE ... WHERE status = 'legacy_value'). - Do not mix unrelated DDL/DML in the same migration.
- Keep SQL explicit and minimal.
Constraint Tightening Pattern
When removing allowed values (enum/check):
- Backfill existing rows to valid target value.
- Update default to new value.
- Tighten check/enum constraint.
For large tables or strict uptime targets, evaluate staged constraint validation supported by the actual database and driver. PostgreSQL NOT VALID / VALIDATE CONSTRAINT applies only to supported constraint kinds.
Anti-Patterns
- Hand-editing generated schema migration files.
- Tightening constraints before backfilling existing data.
- Hiding one-time migration logic in app startup code without migration artifacts.
- Running migrations without validating order in the Drizzle journal.
Reference
- See
references/production-playbook.mdfor command templates and review checklists.
Установить drizzle-safe-migrations в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл drizzle-safe-migrations?
Plan safe Drizzle backfills, enum/check/default changes, constraint tightening, migration ordering, and rollback. Excludes other ORMs, query optimization, and new-schema design.
Как установить скилл drizzle-safe-migrations?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл drizzle-safe-migrations запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
frontend-design
Guidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making…
от Anthropicwebapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing…
от Anthropicbrand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand…
от Anthropicweb-artifacts-builder
Suite of tools for creating elaborate, multi-component claude.ai HTML artifacts using modern frontend web technologies (React, Tailwind CSS, shadcn/ui). Use…
от Anthropic