Database
Schema
Database tables and relationships in Creator.
The schema is defined in lib/db/schema.ts using Drizzle ORM's PostgreSQL schema builder.
Tables
| Table | Description |
|---|---|
user | User accounts with email, password, role, and notification preferences |
oauthAccount | OAuth provider accounts (Google, GitHub) linked to users |
verificationToken | Email verification OTP tokens |
passwordResetToken | Password reset tokens |
emailChangeToken | Email change verification tokens |
userSubscription | Stripe/Lemon Squeezy subscription records (one per user) |
order | Payment records for revenue tracking |
See lib/db/schema.ts for full column definitions.
Relations
- A user has many accounts and orders
- A user has one subscription
- Deleting a user cascades to accounts, subscriptions, and email change tokens
- Deleting a user sets
userIdto null on orders (preserving revenue data)
Type exports
import type { User, NewUser, Account, NewAccount,
UserSubscription, NewUserSubscription,
Order, NewOrder, EmailChangeToken } from "@/lib/db/schema";