Agent skill · software engineering · lobehub

db-migrations

Use for Drizzle migration rollout, online indexes, backfills, idempotent SQL and migration regeneration or rebase conflicts.

Why this skill is useful

Provides specific commands and strategies for managing database migrations that the AI wouldn't reliably generate on its own.

What it needs

Requires bun installed locally. About 8k tokens when loaded. Last updated 2026-08-07. 81,352 stars on the source repository.

What this skill does

Database Migrations Guide Schema conventions Apply these before generating any migration — they change what the schema file looks like, not just the SQL. No pg enums (and no fixed value sets) for growing domains. For columns whose value set will keep expanding (resource types, statuses, providers, …), use a plain text column typed via .$type<UnionType>(). pgEnum requires an ALTER TYPE ... ADD VALUE migration for every new literal, and even the Drizzle text('col', { enum: [...] }) option hardwires the value list into the schema file. With .$type<>(), onboarding a new value is a type-only change — no migration at all. Keep domain constants out of schema files. In new or modified schema files under packages/database/src/schemas/, shared domain literal arrays, union types, and option interfaces belong in @lobechat/types (one module per domain, re-exported from its index.ts); both the schema (.$type<>()) and consumers (routers via z.enum(...), services, UI) import from there. This rule targets domain constants only — table objects, inferred row types, Drizzle relation objects, and zod insert/select schemas (insertAgentSchema, …) are the schema file's job and stay put. Existing schema files that already export such constants (e.g. resourcePermission.ts) are grandfathered; migrate them opportunistically when the file is next touched, not in bulk. Prefixed ids only for rows that are addressed one at a time. An idGenerator prefix (task, cmt, brf) earns its keep when the id turns up somewhere a person reads it — a URL segment, an API argument, a tool-call payload, a support ticket. A child table whose rows are only ever fetched in bulk for their parent takes a plain uuid instead, like taskdependencies / taskdocuments / tasktopics; there the prefix costs a registry entry in idGenerator.ts and buys nothing back. Column order: identity → scope → the table's own columns → visibility → timestamps. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills lobehub/db-migrations--8b72eb

View the source on GitHub

Browse the @skills marketplace