Agent skill · Databases

db-migrations

Use for database rollout strategy, Drizzle migrations, online index creation, data backfills, migration regeneration, sequence conflicts after rebase, idempotent SQL review, or migration renames.

LobeHub80,937★ · +310/wk · 1 repos on radarProfile →
claude-codeNOASSERTION
Install
npx skills add lobehub/lobehub --skill db-migrations --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 1
SKILL.md size: 9 KB
Bundled scripts: none
Path: .agents/skills/db-migrations/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 81,252 · +315 this week
Language: TypeScript
Read our review of the source →

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# Database Migrations Guide ## Choose the rollout strategy Classify every database change into one of these three rollout paths before generating or editing a migration. ### 1. Regular Drizzle migration Use the normal Drizzle workflow for schema changes that are safe to execute during deployment, such as creating a small table or adding a nullable column: 1. Update the Drizzle schema. 2. Run `bun run db:generate`. 3. Review and harden the generated artifacts using the steps below. Before listing a manual migration command as a release step, inspect the target repository's build and deployment scripts. If its deployment pipeline already applies migrations automatically, do not require a redundant manual run. ### 2. Online index creation Creating an index normally can block writes and queries on a large or frequently accessed table, and a long-running statement can also stall the deployment. In that case: 1. Before deploying the application, execute the index creation manually in the target database's SQL editor using `CONCURRENTLY`: ```sql CREATE INDEX CONCURRENTLY IF NOT EXISTS "table_column_idx" ON "table" USING btree ("column"); ``` 2. Keep an idempotent, non-`CONCURRENTLY` versi

What's inside
Steps it walks through
  1. Choose the rollout strategy
  2. 1. Regular Drizzle migration
  3. 2. Online index creation
  4. 3. Data backfill
  5. Development-stage schema changes
  6. Rebase conflicts
  7. Step 1: Generate Migrations
  8. Custom Migrations (e.g. CREATE EXTENSION)
  9. Step 2: Optimize Migration SQL Filename
  10. Step 3: Use Idempotent Clauses (Defensive Programming)
  11. CREATE TABLE
  12. ALTER TABLE - Columns
  13. ALTER TABLE - Foreign Key Constraints
  14. DROP TABLE / INDEX
Commands it runs
rm packages/database/migrations/0110_add_verify_tables_and_ai_infra_id.sql
rm packages/database/migrations/meta/0110_snapshot.json
packages/database/migrations/meta/_journal.json
bun run db:generate
rm packages/database/migrations/011{0,1,2}_*.sql
rm packages/database/migrations/meta/011{0,1,2}_snapshot.json
Fix the dev DB to match the new schema (simplest SQL wins)
set -a && source .env && set +a && bun -e '
import pg from "pg";
const client = new pg.Client({ connectionString: process.env.DATABASE_URL });
More from lobehub
All skills →
About this skill
What does the db-migrations skill do?

Use for database rollout strategy, Drizzle migrations, online index creation, data backfills, migration regeneration, sequence conflicts after rebase, idempotent SQL review, or migration renames.

How do I install it?

Run `npx skills add lobehub/lobehub --skill db-migrations --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From lobehub/lobehub, a repository with 81,252 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going