Skip to main content
Juliano Alves
Back to blog

Drizzle ORM: TypeScript-first SQL

2 min read
By Juliano Alves

Drizzle models your schema in TypeScript, generates SQL migrations, and exposes a query builder that stays close to SQL—appealing when Prisma’s abstraction feels too opaque or heavy at runtime.

Schema definition#

import { pgTable, text, timestamp, uuid } from 'drizzle-orm/pg-core';

export const users = pgTable('users', {
  id: uuid('id').defaultRandom().primaryKey(),
  email: text('email').notNull().unique(),
  createdAt: timestamp('created_at', { withTimezone: true }).defaultNow(),
});

drizzle-kit emits SQL migrations from schema diffs—review like any DDL.

Queries#

import { eq } from 'drizzle-orm';

const row = await db.select().from(users).where(eq(users.email, 'a@b.com'));

Types flow from table definitions; you can drop to sql tagged template for complex CTEs.

When Prisma still wins#

Prisma’s DX for nested writes and client ergonomics is hard to beat for CRUD-heavy apps. Drizzle shines when you want transparent SQL, lighter bundles, or multi-schema Postgres control.

Summary#

Drizzle is a strong choice for teams that think in SQL but want types. Pair with strict migration review and benchmark hot paths—ORMs never remove the need for indexes and query plans.

© 2026 Juliano Alves. All rights reserved.