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.
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 schemadb:migrate- Run pending migrationsdb:push- Push schema to database (dev)db:studio- Launch Drizzle Studio visual browserdb:seed- Populate database with sample data
Drizzle Kit Configuration:
- Pre-configured
drizzle.config.tswith 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 templateFiles 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 templateDatabase Schema:
User: id, username, email, emailVerified, avatarUrl, phone, firstName, lastName, createdAt, updatedAtPost: id, title, content, published, authorId (FK to User), createdAt, updatedAtSession(if Better Auth): id, userId, token, expiresAt, ipAddress, userAgent, timestampsAccount(if Better Auth): id, userId, accountId, providerId, tokens, scope, password, timestampsVerification(if Better Auth): id, identifier, value, expiresAt, timestamps
Dependencies:
drizzle-orm- ORM librarypgormysql2- Database driverdrizzle-kit(dev) - Migrations CLI@types/pgor@types/mysql2(dev) - TypeScript types

