Creator
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

TableDescription
userUser accounts with email, password, role, and notification preferences
oauthAccountOAuth provider accounts (Google, GitHub) linked to users
verificationTokenEmail verification OTP tokens
passwordResetTokenPassword reset tokens
emailChangeTokenEmail change verification tokens
userSubscriptionStripe/Lemon Squeezy subscription records (one per user)
orderPayment 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 userId to null on orders (preserving revenue data)

Type exports

import type { User, NewUser, Account, NewAccount,
  UserSubscription, NewUserSubscription,
  Order, NewOrder, EmailChangeToken } from "@/lib/db/schema";

On this page

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.