Database Stack
Drizzle ORM
Type-safe ORM with SQL-like syntax
PostgreSQL
Production-ready relational database
Why Drizzle?
Drizzle ORM offers several advantages for this boilerplate:- Type Safety: Full TypeScript inference for queries and schema
- Performance: Generates efficient SQL with minimal overhead
- Simplicity: SQL-like syntax that’s easy to learn
- Migration Tools: Built-in migration generation and management
- Better Auth Integration: Seamlessly works with Better Auth’s schema requirements
Configuration
The database is configured indrizzle.config.ts:
drizzle.config.ts
The
DATABASE_URL environment variable should be set in your .env file to point to your PostgreSQL instance.Database Schema
The schema is defined insrc/db/schema.ts and includes five tables that are auto-generated by Better Auth:
- user - User accounts and profiles
- session - Active user sessions
- account - OAuth provider accounts
- verification - Email verification tokens
- jwks - JSON Web Key Sets for JWT verification
Basic Usage
Once your schema is defined and pushed to the database, you can query it using Drizzle:Better Auth manages user creation automatically. You typically won’t need to manually insert users.
Available Commands
The boilerplate includes several npm scripts for database management:| Command | Description |
|---|---|
npm run db:push | Push schema directly to DB (development) |
npm run db:generate | Generate SQL migration files |
npm run db:migrate | Run pending migrations |
npm run db:studio | Open Drizzle Studio (visual DB browser) |
Next Steps
Schema
Explore the complete database schema
Migrations
Learn about database migrations
Adding Tables
Add custom tables to your database
Drizzle Docs
Official Drizzle ORM documentation