Create FasterCreate Faster

Drizzle

Drizzle ORM is a lightweight, TypeScript-first ORM with zero overhead and SQL-like syntax for maximum type safety.

Presentation

Type-safe database access with Drizzle ORM, including schema with User/Post models, Better Auth tables, migrations, and seeding scripts.

→ Drizzle ORM Documentation

Requires: Database (PostgreSQL or MySQL)

What create-faster adds

Beyond the official setup, we include:

Pre-configured Schema:

  • User and Post models with relations
  • Better Auth tables (Session, Account, Verification) when auth module selected
  • UUID primary keys, timestamps, foreign keys

Development Scripts:

  • db:generate - Generate SQL migrations from schema
  • db:migrate - Run pending migrations
  • db:push - Push schema to database (dev)
  • db:studio - Launch Drizzle Studio visual browser
  • db:seed - Populate database with sample data

Drizzle Kit Configuration:

  • Pre-configured drizzle.config.ts with dialect detection
  • Verbose and strict mode enabled
  • Schema path auto-configured based on repo type

Seed Script:

  • Sample Users (Alice, Bob) and Posts
  • Demonstrates relations and .returning()

Files created (Turborepo):

packages/db/
├── src/
│   ├── schema.ts           # Database schema with User, Post, auth tables
│   ├── types.ts            # Inferred TypeScript types
│   └── index.ts            # Database connection with SSL config
├── scripts/
│   └── seed.ts             # Seed script with sample data
├── drizzle.config.ts       # Drizzle Kit configuration
├── package.json            # Dependencies and db:* scripts
├── tsconfig.json           # TypeScript config
└── .env.example            # DATABASE_URL template

Files created (Single repo):

src/lib/db/
├── schema.ts               # Database schema
├── types.ts                # Inferred types
└── index.ts                # Database connection

scripts/
└── seed.ts                 # Seed script

drizzle.config.ts           # Drizzle Kit config
.env.example                # DATABASE_URL template

Database Schema:

  • User: id, username, email, emailVerified, avatarUrl, phone, firstName, lastName, createdAt, updatedAt
  • Post: id, title, content, published, authorId (FK to User), createdAt, updatedAt
  • Session (if Better Auth): id, userId, token, expiresAt, ipAddress, userAgent, timestamps
  • Account (if Better Auth): id, userId, accountId, providerId, tokens, scope, password, timestamps
  • Verification (if Better Auth): id, identifier, value, expiresAt, timestamps

Dependencies:

  • drizzle-orm - ORM library
  • pg or mysql2 - Database driver
  • drizzle-kit (dev) - Migrations CLI
  • @types/pg or @types/mysql2 (dev) - TypeScript types

On this page