Docs

Search documentation

Jump to a documentation page.

PricingMarketingApp

Search documentation

Jump to a documentation page.

Schema

Database schema

Postgres schema is defined in Drizzle as packages/server/src/db/schema.ts. Migrations live under the monorepo migration workflow (see root drizzle.config.ts and app db:* scripts).

Design principles

  • Multi-tenant — business entities that belong to a customer workspace include organization_id (or equivalent FK).
  • Better Authusers, sessions, accounts, and verifications follow Better Auth conventions (string ids where required).

Enums (Postgres)

EnumValues
org_roleowner, admin, member
subscription_statusactive, trialing, past_due, canceled, incomplete
notification_severitynormal, critical
platform_banner_placementlanding, app, everywhere
platform_banner_variantinfo, warning, critical
task_statusbacklog, todo, in_progress, in_review, done
task_prioritylow, medium, high

Core tables

TablePurpose
usersProfiles, email, password hash, Better Auth admin role, ban fields, welcome onboarding timestamp.
organizationsWorkspace name, slug, logo.
organization_membersUser ↔ org membership and org_role. Unique (organization_id, user_id).
organization_invitationsPending invites: email, role, token_hash, expiry, accept/revoke timestamps.
subscriptionsOne row per org: Stripe customer/subscription/price ids, status, period, cancel-at-period-end.
api_keysPer-org API keys: hashed secret, prefix, last used.

Product / operator tables

TablePurpose
tasks / task_assigneesOrg-scoped tasks and assignees.
eventsAnalytics-style events (optional org/user FKs).
audit_log_entriesOrg-scoped audit trail.
webhook_endpoints / webhook_deliveriesOutbound webhooks and delivery log.
user_notifications / user_notification_preferencesIn-app notifications and preferences.
platform_onboarding_configWelcome wizard copy and steps.
platform_feature_flagsOperator feature toggles.
platform_bannersAnnouncement bars (placement, variant, schedule).

Better Auth tables

TablePurpose
sessionsSession token, expiry, user id, optional impersonated_by (admin impersonation).
accountsOAuth and credential links per provider.
verificationsEmail verification and reset tokens.

TypeScript types

Drizzle infers $inferSelect / $inferInsert types exported next to each table in schema.ts for use in server code.

Related