Database Tables

users

User table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
avatar_urlTEXTAvatar URL
first_nameVARCHAR(255)First name
last_nameVARCHAR(255)Last name
usernameVARCHAR(255)Username
passwordTEXTPassword (argon2 hashed)
roleVARCHAR(20)memberSystem role (owner / member)
statusVARCHAR(20)activeStatus (active / disabled)
created_atBIGINTnowCreated at
updated_atBIGINTnowUpdated at
deleted_atBIGINTNULLSoft delete timestamp

user_emails

User emails table. Supports multiple emails per user.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
user_idUUIDUser ID
emailTEXTEmail
is_primaryBOOLEANfalsePrimary email
verifiedBOOLEANfalseEmail verified
viaVARCHAR(80)email:passwordSignup source (email:password / google)
created_atBIGINTnowCreated at
updated_atBIGINTnowUpdated at

Unique constraints: (user_id, email), (user_id, is_primary)

user_provider_customers

Third-party payment customer ID mapping.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
user_idUUIDUser ID
user_email_idUUIDUser email ID
providerVARCHAR(50)Payment provider (stripe)
customer_idVARCHAR(255)Provider customer ID
created_atBIGINTnowCreated at

Unique constraint: (user_id, provider)

user_email_preferences

Email subscription preferences.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
user_idUUIDUser ID
email_typeVARCHAR(50)Email type (marketing / product_updates / payment_receipts)
subscribedBOOLEANtrueSubscribed
created_atBIGINTnowCreated at
updated_atBIGINTnowUpdated at

Unique constraint: (user_id, email_type)

tenants

Tenant (organization) table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
nameVARCHAR(255)Org name
slugVARCHAR(255)URL slug (unique)
logo_urlTEXTLogo
owner_idUUIDCreator ID
is_defaultBOOLEANfalseDefault org
deleted_atBIGINTSoft delete timestamp
created_atBIGINTnowCreated at
updated_atBIGINTnowUpdated at

tenant_members

Tenant membership table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
tenant_idUUIDOrg ID
user_idUUIDUser ID
roleVARCHAR(20)memberRole (owner / member / custom)
created_atBIGINTnowJoined at
updated_atBIGINTnowUpdated at

Unique constraint: (tenant_id, user_id)

tenant_invitations

Tenant invitation table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
tenant_idUUIDOrg ID
emailVARCHAR(255)Invitee email
roleVARCHAR(20)memberAssigned role
invited_byUUIDInviter ID
tokenVARCHAR(255)Invitation token (unique)
statusVARCHAR(20)pendingStatus (pending / accepted)
credit_limitINTEGER-1Credit limit (-1 = unlimited)
expires_atBIGINTExpiration time
created_atBIGINTnowCreated at

Unique constraint: (tenant_id, email)

tenant_member_credit_limits

Member credit limit table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
tenant_idUUIDOrg ID
user_idUUIDMember ID
credit_limitINTEGER-1Credit limit (-1 = unlimited)
used_creditsINTEGER0Credits used
created_atBIGINTnowCreated at
updated_atBIGINTnowUpdated at

Unique constraint: (tenant_id, user_id)

subscriptions

Subscription table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
providerVARCHAR(50)stripePayment provider
user_idUUIDUser ID
tenant_idUUIDOrg ID
plan_idVARCHAR(255)Plan ID
statusVARCHAR(20)pendingStatus (active / pending / canceled / past_due)
amountINTEGERAmount (cents)
currencyVARCHAR(10)usdCurrency
provider_subscription_idVARCHAR(255)Stripe subscription ID (unique)
provider_customer_idVARCHAR(255)Stripe customer ID
provider_price_idVARCHAR(255)Stripe price ID
current_period_startBIGINTCurrent period start
current_period_endBIGINTCurrent period end
canceled_atBIGINTNULLCanceled at
raw_dataJSONBStripe raw data
created_atBIGINTnowCreated at
updated_atBIGINTnowUpdated at

credits

Credits table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
providerVARCHAR(50)stripePayment provider
user_idUUIDUser ID
tenant_idUUIDOrg ID
plan_idVARCHAR(255)Plan ID
modeVARCHAR(100)Source (free / subscription / one_time:credits)
total_creditsBIGINTTotal credits
remaining_creditsBIGINTRemaining credits
amountINTEGER0Amount (cents)
currencyVARCHAR(10)usdCurrency
priorityINTEGER50Consumption priority (higher = consumed first)
source_typeVARCHAR(100)Event type (checkout.session.completed, etc.)
source_idVARCHAR(255)Event ID
provider_price_idVARCHAR(255)Stripe price ID
provider_customer_idVARCHAR(255)Stripe customer ID
expires_atBIGINTNULLExpiration (NULL = never)
effective_atBIGINTEffective from
raw_dataJSONBStripe raw data
created_atBIGINTnowCreated at

Unique constraint: (user_id, source_id)

credit_transactions

Credit transaction records.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
user_idUUIDUser ID
tenant_idUUIDOrg ID
credit_idUUIDCredit package ID
creditsINTEGERCredit amount
typeVARCHAR(50)Type (add:purchase / deduct / deduct:overdraft)
descriptionTEXTDescription
created_atBIGINTnowCreated at

credit_overdrafts

Credit overdraft records.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
user_idUUIDUser ID
tenant_idUUIDOrg ID
creditsBIGINTOverdraft credits
created_atBIGINTnowCreated at
updated_atBIGINTnowUpdated at

lifetime

Lifetime deal table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
providerVARCHAR(50)stripePayment provider
user_idUUIDUser ID
tenant_idUUIDOrg ID
plan_idVARCHAR(255)Plan ID
amountINTEGERAmount (cents)
currencyVARCHAR(10)usdCurrency
provider_price_idVARCHAR(255)Stripe price ID
provider_customer_idVARCHAR(255)Stripe customer ID
provider_payment_intent_idVARCHAR(255)Stripe PaymentIntent ID
provider_checkout_session_idVARCHAR(255)Stripe Session ID (unique)
raw_dataJSONBStripe raw data
created_atBIGINTnowCreated at

invoices

Invoice table.

ColumnTypeDefaultDescription
idUUIDautoPrimary key
providerVARCHAR(50)stripePayment provider
user_idUUIDUser ID
tenant_idUUIDOrg ID
plan_idVARCHAR(255)Plan ID
amountINTEGERAmount (cents)
currencyVARCHAR(10)usdCurrency
billing_reasonVARCHAR(50)Reason (subscription_create / subscription_cycle / manual)
provider_invoice_idVARCHAR(255)Stripe invoice ID (unique)
provider_price_idVARCHAR(255)Stripe price ID
provider_customer_idVARCHAR(255)Stripe customer ID
invoice_pdfTEXTInvoice PDF URL
receipt_pdfTEXTReceipt PDF URL
hosted_invoice_urlTEXTOnline view URL
raw_dataJSONBStripe raw data
paid_atBIGINTPaid at

prices

Price table (synced from Stripe).

ColumnTypeDefaultDescription
idUUIDautoPrimary key
providerVARCHAR(50)stripePayment provider
provider_price_idVARCHAR(255)Stripe Price ID
product_idVARCHAR(255)Stripe Product ID
activeBOOLEANtrueActive
currencyVARCHAR(3)Currency
unit_amountINTEGERUnit price (cents)
billing_schemeVARCHAR(50)Billing scheme (per_unit)
typeVARCHAR(50)Type (recurring / one_time)
intervalVARCHAR(20)Interval (month / year)
interval_countINTEGERInterval count
trial_period_daysINTEGERTrial days
usage_typeVARCHAR(50)Usage type (licensed / metered)
metadataJSONBMetadata
raw_dataJSONBStripe raw data
created_atTIMESTAMPNOW()Created at
updated_atTIMESTAMPNOW()Updated at

Unique constraint: (provider, provider_price_id)