users table stores core user account information and links to Dodo customer records.
Source: ~/workspace/source/lib/drizzle/schema.ts:12-28
Table Definition
Fields
Primary KeySupabase authentication user ID. Links to Supabase Auth.This is the unique identifier for each user in your application.
Dodo Payments customer identifier.Used in webhook handlers to identify the customer when processing payment and subscription events.Referenced in:
updateUserTier()at supabase/functions/dodo-webhook/index.ts:208downgradeToHobbyPlan()at supabase/functions/dodo-webhook/index.ts:216
NullableReferences the active subscription ID from the
subscriptions table.- Set to subscription ID when user has an active paid plan
- Set to
nullwhen user is on free tier or subscription ends - Updated automatically by webhook events
subscription.active- Sets to new subscription IDsubscription.plan_changed- Updates to new subscription IDsubscription.cancelled- Sets tonullsubscription.expired- Sets tonullsubscription.failed- Sets tonull
With timezoneTimestamp when the user record was created.Stored as ISO 8601 string with timezone information.
With timezoneTimestamp when the user record was last updated.Stored as ISO 8601 string with timezone information.
Nullable, With timezoneSoft delete timestamp. When set, indicates the user account has been deleted.Stored as ISO 8601 string with timezone information.
Relations
Defined at: lib/drizzle/schema.ts:111-117currentSubscription (one-to-one)
Links to the user’s current active subscription.Foreign key:
users.current_subscription_id → subscriptions.subscription_idsubscriptions (one-to-many)
All subscriptions associated with this user (historical and current).Inverse relation through
subscriptions.user_idTypeScript Types
Defined at: lib/drizzle/schema.ts:126-127SelectUser
Type for reading user records from the database.InsertUser
Type for inserting new user records.Usage in Webhook Handlers
Updating User Subscription Status
When subscription becomes active (webhook events:subscription.active, subscription.plan_changed):
Downgrading User to Free Tier
When subscription ends (webhook events:subscription.cancelled, subscription.expired, subscription.failed):
Query Examples
Get User with Current Subscription
Get All Active Subscribers
Check User Subscription Status
Related Tables
Subscriptions Schema
View the subscriptions table schema
Payments Schema
View the payments table schema
