From harness-claude
Manages Drizzle schema evolution using drizzle-kit: generate/push/apply migrations, introspect databases for prototyping and production workflows.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Manage Drizzle schema evolution with drizzle-kit generate/push/migrate and introspect
Evolves database schemas safely with Drizzle/Prisma migrations, zero-downtime strategies, rollbacks, backfills, and data validation for production without downtime or data loss.
Guides schema management and migrations using Drizzle ORM with SQLite in TypeScript projects. Edit schema.ts, generate migrations via pnpm db:generate, and apply safely on dev startup.
Provides expertise in Drizzle ORM for TypeScript: schema design, relational queries, Drizzle Kit migrations, and serverless integrations with Neon, Supabase, PlanetScale.
Share bugs, ideas, or general feedback.
Manage Drizzle schema evolution with drizzle-kit generate/push/migrate and introspect
pushdrizzle.config.ts:import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './src/db/schema.ts',
out: './drizzle',
dialect: 'postgresql',
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
npx drizzle-kit generate
This creates a SQL migration file in the out directory (e.g., drizzle/0001_add_posts_table.sql).
import { migrate } from 'drizzle-orm/node-postgres/migrator';
import { db } from './db';
await migrate(db, { migrationsFolder: './drizzle' });
npx drizzle-kit push
Use push only in development. It does not create reversible migration history.
npx drizzle-kit introspect
This creates a TypeScript schema file matching the current database structure.
Review generated SQL before applying. Open the migration file and verify:
Custom migration SQL — edit generated files to add data migrations:
-- Generated: add status column
ALTER TABLE "posts" ADD COLUMN "status" text DEFAULT 'draft' NOT NULL;
-- Custom: backfill existing records
UPDATE "posts" SET "status" = 'published' WHERE "published" = true;
npx drizzle-kit check
npx drizzle-kit drop
Drizzle Kit is the CLI companion to Drizzle ORM. It reads your TypeScript schema and generates SQL migration files by diffing the schema against the migration history.
Migration tracking: Drizzle creates a __drizzle_migrations table in the database to track which migrations have been applied. Each migration is identified by its filename hash.
generate vs push: generate creates versioned, reversible migration files for production workflows. push applies changes directly — fast for prototyping but leaves no history. Never use push in environments shared with other developers or in CI/CD.
Migration file structure:
drizzle/
0000_initial.sql
0001_add_posts.sql
0002_add_comments.sql
meta/
0000_snapshot.json
0001_snapshot.json
_journal.json
The meta/ directory contains schema snapshots that drizzle-kit uses to compute diffs. Do not edit these files.
Programmatic migration: Unlike Prisma's migrate deploy CLI command, Drizzle recommends running migrations in application code at startup. This works well for serverless environments where you cannot run CLI commands.
Trade-offs:
push is fast but dangerous — it can drop columns without warning in developmentreset command — drop the database manually and re-run migrations for a clean slatehttps://orm.drizzle.team/docs/migrations