Using Drizzle Kit with a Local Cloudflare D1 Database
Use Drizzle Kit with Cloudflare D1 locally. Resolve SQLite paths, handle bindings, and simplify migrations with @deox/drizzle-d1-utils.
Using Drizzle Kit with a Local Cloudflare D1 Database
Use Drizzle Kit with Cloudflare D1 locally. Resolve SQLite paths, handle bindings, and simplify migrations with @deox/drizzle-d1-utils. Cloudflare D1 is a great fit for full-stack Workers projects. Drizzle ORM is a great fit for type-safe SQL in TypeScript. On paper they belong together — but when you try to wire up Drizzle Kit for migrations against a local D1 database, you quickly discover there's a gap nobody has cleanly filled. This article covers what that gap is, why it exists, and how @deox/drizzle-d1-utils closes it. How Drizzle Kit Supports D1 — and Where It Stops Drizzle Kit has a d1-http driver. You configure it in drizzle.config.ts like this: // drizzle.config.ts
import type { Config } from 'drizzle-kit';
export default {
dialect: 'sqlite',
driver: 'd1-http',
dbCredentials: {
databaseId: 'your-database-id',
accountId: process.env.CF_ACCOUNT_ID!,
token: process.env.CF_API_TOKEN!,
},
schema: './src/schema.ts',
o…