Back to posts

Drizzle ORM — From Setup to Schema in Minutes

10/19/2025

I recently tried Drizzle ORM, and honestly — I thought it would be tough.
But within minutes, I was writing schemas, connecting to the database, and running queries like I’d been using it for months.


⚙️ Quick Setup Flow

The setup was surprisingly easy.
I used MySQL for my first test — connected through drizzle-orm/mysql2, and everything just worked.

import { drizzle } from "drizzle-orm/mysql2";
import mysql from "mysql2/promise";

const connection = await mysql.createConnection({
  host: "localhost",
  user: "root",
  password: "password",
  database: "test_db",
});

const db = drizzle(connection);

Once connected, I could define a schema instantly:

import { mysqlTable, serial, varchar, int } from "drizzle-orm/mysql-core";

export const users = mysqlTable("users", {
  id: serial("id").primaryKey(),
  name: varchar("name", { length: 255 }).notNull(),
  age: int("age").default(18),
});

That’s it — no magic, no complicated config files. Just clean, readable TypeScript.


🧩 MySQL Workbench vs. pgAdmin

Coming from PostgreSQL and pgAdmin, I found MySQL Workbench a bit dull. It’s functional, but not fun. Still, once Drizzle was connected, I didn’t need to spend much time inside Workbench — Drizzle’s CLI and schema approach gave me full control right from VS Code.


⚡ Why Drizzle Feels Powerful

Compared to Prisma, Drizzle gives you more control. It doesn’t hide SQL from you — it embraces it. You can write custom queries, joins, and still enjoy full TypeScript safety.

// Select with conditions
const adults = await db.select().from(users).where(eq(users.age, 18));

// Inner join example
const result = await db
  .select({
    user: users.name,
    post: posts.title,
  })
  .from(users)
  .innerJoin(posts, eq(users.id, posts.userId));

The generated SQL is clean and optimized, and the performance is impressive. For developers who care about what actually happens under the hood — this is a huge plus.


🧭 Migrations Made Simple

Drizzle’s migration system is just as developer-friendly. You can generate and run migrations using the CLI:

npx drizzle-kit generate:mysql
npx drizzle-kit push:mysql

No heavy config, no hidden scripts. It’s straightforward and versioned cleanly — perfect for teams or solo devs.


🐘 Next Step: PostgreSQL

I’m planning to connect PostgreSQL next and run some performance checks. From what I’ve seen, Drizzle’s Postgres adapter performs even better — native joins, advanced query plans, and full SQL transparency.

If it handles as smoothly as MySQL, this might become my go-to ORM for new projects.


💬 Final Thought

Drizzle feels light, transparent, and fast. It doesn’t try to abstract away SQL — it makes it easier to love SQL again. If you’ve struggled with heavy ORMs before, Drizzle might just be the breath of fresh air you’ve been waiting for.

#drizzle#orm#typescript#mysql#postgresql
0views