roninforge/roninforge-drizzle/drizzle-migrate-to-v1

Claude Code and agent skill by roninforge/roninforge-drizzle

Trust tier 3
  • community
Source check pending

Checking that the SKILL.md file is still in the repository.

Migrate a Drizzle codebase from 0.x to 1.0-rc: bump pins, codemod the pgArray import path, codemod or remove the casing API on drizzle(), rewrite relations() as defineRelations(), move enableRLS() to pgTable.withRLS(), regenerate migrations and confirm.

Install

npx vskill@latest install roninforge/roninforge-drizzle/drizzle-migrate-to-v1

SKILL.md

The same SKILL.md was published earlier as roninforge/roninforge-drizzle/drizzle-migrate-to-v1.

Migrate Drizzle 0.x to 1.0-rc

When to Use

When you are ready to move a project from drizzle-orm@0.45.x (current stable) to drizzle-orm@1.0.0-rc.x.

Status note: as of May 2026 v1.0 has been in RC for over a year. The API is stable across recent RCs but a final 1.0.0 tag has not shipped. Do this migration only on new projects or when you specifically need a v1-only feature (Effect v4 native support, RQB v2). For prod systems, stay on 0.45.x until v1 stable lands.

Instructions

Apply in order. Build and run tests after each step.

Step 1: Pin v1 RC
bash
pnpm add drizzle-orm@rc drizzle-kit@rc

package.json should read approximately:

jsonc
{
"dependencies": { "drizzle-orm": "1.0.0-rc.2" },
"devDependencies": { "drizzle-kit": "1.0.0-rc.2" }
}

Commit. The build will be broken until step 4 is done.

Step 2: Codemod the pgArray import path
bash
find src -name '*.ts' -print0 | xargs -0 sed -i.bak \
-e 's|from "drizzle-orm/pg-core/utils"|from "drizzle-orm/pg-core/array"|g' \
-e "s|from 'drizzle-orm/pg-core/utils'|from 'drizzle-orm/pg-core/array'|g"
find src -name '*.ts.bak' -delete

Verify nothing else was importing from pg-core/utils (it was only pgArray in v0):

bash
grep -rn "drizzle-orm/pg-core/utils" --include='*.ts' src/
# should return zero hits
Step 3: Remove the casing: config from drizzle()

In src/db/index.ts (or wherever you call drizzle()):

typescript
// BEFORE
const db = drizzle(pool, { schema, casing: "snake_case" });
// AFTER
const db = drizzle(pool, { schema });

If you actually need snake_case mapping, switch to per-table builders. Pick one of:

Option A: rewrite each table to use `snakeCase.table(...)` (explicit, more code):

typescript
// BEFORE
import { pgTable, varchar } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
firstName: varchar({ length: 64 }),
});
// AFTER
import { snakeCase } from "drizzle-orm/casing";
import { varchar } from "drizzle-orm/pg-core";
export const users = snakeCase.table("users", {
firstName: varchar({ length: 64 }),
});

Option B: switch to explicit column-name overrides (more verbose per column but no new import):

typescript
export const users = pgTable("users", {
firstName: varchar("first_name", { length: 64 }),
});

Option A is shorter for tables with many columns. Option B is more explicit and survives if you later migrate off Drizzle.

Step 4: Rewrite relations() as defineRelations()

The v0 relations() API splits across multiple files. The v1 defineRelations is a single call.

typescript
// BEFORE - src/db/relations.ts
import { relations } from "drizzle-orm";
import { users } from "./schema/users";
import { posts } from "./schema/posts";
export const userRelations = relations(users, ({ many }) => ({
posts: many(posts),
}));
export const postRelations = relations(posts, ({ one }) => ({
user: one(users, { fields: [posts.userId], references: [users.id] }),
}));

The v1 defineRelations takes the schema object plus a callback that defines relations for each table in a single nested object. The exact callback shape has changed between RC versions, so do not copy a snippet from a blog post. Read the current shape from the official source before writing your own:

Then wire the result into the drizzle() call. The exact key name and spread shape for defineRelations output also changed between RCs, so do not copy a wiring snippet from this doc. Open node_modules/drizzle-orm/index.d.ts after install and read the drizzle() constructor's options type for the RC you pinned.

v1 is RC. Both the defineRelations callback and the drizzle() options shape have shifted across 1.0.0-rc.x releases. Pin a single RC version and treat the relations file plus the drizzle() call as the two places to re-check on every RC bump.
Step 5: Move RLS from enableRLS() to pgTable.withRLS(...)
typescript
// BEFORE
export const docs = pgTable("docs", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
userId: text().notNull(),
}, (t) => [
pgPolicy("owner_select", { for: "select", using: sql`user_id = (auth.uid())::text` }),
]).enableRLS();
// AFTER
export const docs = pgTable.withRLS("docs", {
id: integer().primaryKey().generatedAlwaysAsIdentity(),
userId: text().notNull(),
}, (t) => [
pgPolicy("owner_select", { for: "select", using: sql`user_id = (auth.uid())::text` }),
]);

.enableRLS() is removed in v1.

Step 6: Regenerate migration snapshots

The internal snapshot format may have changed. Regenerate from the current schema:

bash
# Back up the existing snapshot folder
mv drizzle/meta drizzle/meta.v0.bak
# Regenerate
pnpm drizzle-kit generate

Review the regenerated migration. If your DB is already at the target schema, no SQL diff should be produced. If a diff appears, investigate before applying.

Step 7: Verify
bash
pnpm tsc --noEmit
pnpm test

If tests pass and tsc is clean, the migration succeeded. Commit.

If tests fail with db.query.X.findMany errors, RQB v2 has subtle behavior differences from v1 - read the relations v1-to-v2 doc and adjust the call sites.

Optional: Effect v4 Schema integration

If you use Effect Schema for validation, v1 ships first-party Effect v4 support and replaces the old drizzle-effect package. The exact export name and signature have shifted across RCs - check the changelog for the RC you pinned and read the export list from node_modules/drizzle-orm/effect/ before writing call sites.

Rollback plan

If anything breaks badly:

bash
git revert HEAD~N..HEAD # back out the migration commits
pnpm install # restore old lockfile
mv drizzle/meta.v0.bak drizzle/meta # restore snapshot folder

You're back on 0.45.x. The schema files and queries are unchanged at the SQL level - only the TypeScript surface changes between v0 and v1.

What NOT to do

  • Do not mix v0 and v1 in the same project. The two RQB shapes are incompatible.
  • Do not delete drizzle/meta/ without backing it up first.
  • Do not run drizzle-kit push to "fix" a generation diff - inspect the diff and either accept or revert at the schema level.
  • Do not migrate prod traffic until you have run integration tests against a v1-pinned copy of staging for at least a week.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewPassed

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
5

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/roninforge/roninforge-drizzle/drizzle-migrate-to-v1/badge)](https://verified-skill.com/skills/roninforge/roninforge-drizzle/drizzle-migrate-to-v1)

Something wrong with this skill or its page? Tell us.