Schema Definition
Define your database schema with Drizzle ORM
Schema File
The database schema is defined in `src/db/schema.ts`:
typescript
export const users = pgTable('users', { id: text('id').primaryKey(), name: text('name').notNull(), email: text('email').notNull().unique(), emailVerified: boolean('email_verified').default(false), image: text('image'), role: text('role').default('member'), createdAt: timestamp('created_at').defaultNow(), updatedAt: timestamp('updated_at').defaultNow(), }); ```
Available Tables
- **users** - User accounts
- **sessions** - Auth sessions
- **accounts** - OAuth accounts
- **subscriptions** - Stripe subscriptions
- **organizations** - Teams/organizations
- **blogPosts** - Blog content
Adding New Tables
- Define the table in `schema.ts`
- Run migrations: `npm run db:push`
- Use in your code
Type Safety
Drizzle provides full type safety:
typescript
export type User = typeof users.$inferSelect;
export type NewUser = typeof users.$inferInsert;