DB
All tables and fields in the main application database.
DB is the default template's application database. Its initial schema is defined in schema/db-init.sql. This reference covers account, authentication, OAuth 2.0, permission, payment, support ticket, notification, affiliate, and Reaction data by table, including field types, nullability, defaults, and database constraints.
Time and boolean values
Time fields use Unix timestamps in milliseconds. Boolean states are stored as SQLite INTEGER values, typically using 1 for true and 0 for false.
ticket
Stores support ticket lookup fields and status. Ticket bodies are stored in MAIN_KV and linked through kv_id.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
requester_id | INTEGER | No | — | — | ID of the user who submitted the ticket. A value less than or equal to 0 indicates an anonymous requester. |
assignee_id | INTEGER | Yes | — | — | ID of the admin user responsible for handling the ticket. |
kv_id | TEXT | No | — | — | Unique key for the ticket body in MAIN_KV. |
status | TEXT | No | 'open' | — | Current status. |
priority | INTEGER | No | 0 | — | Priority. Higher values indicate higher priority. |
ticket_type | TEXT | Yes | — | — | Ticket type. |
product | TEXT | Yes | — | — | Product associated with the ticket. |
title | TEXT | Yes | — | — | Title. |
name | TEXT | Yes | — | — | Name. |
email | TEXT | Yes | — | — | Email address. |
requester_unread | INTEGER | No | 0 | — | Whether the requester has unread replies. 1 means yes, and 0 means no. |
closed_at | INTEGER | Yes | — | — | Ticket closure time, in Unix milliseconds. |
resolved_at | INTEGER | Yes | — | — | Ticket resolution time, in Unix milliseconds. |
deleted_at | INTEGER | No | 0 | — | Soft deletion time. 0 means not deleted. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | Current Unix time in milliseconds | — | Last update time, in Unix milliseconds. |
newsletter_subscriber
Stores newsletter email addresses, locales, and subscription times.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
email | TEXT | No | — | — | Email address. |
locale | TEXT | No | — | — | Language code. |
subscribed_at | INTEGER | No | Current Unix time in milliseconds | — | Time of subscription to the mailing list, in Unix milliseconds. |
saas_user
Stores user accounts, sign-in providers, two-factor authentication, and affiliate status.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
email | TEXT | Yes | — | — | Email address. |
email_hash | TEXT | No | — | — | Hash of the normalized email address, used for uniqueness checks and secure queries. |
email_verified | INTEGER | No | 0 | — | Whether the email address has been verified. 1 means verified. |
user_name | TEXT | No | — | — | Username. |
display_name | TEXT | Yes | — | — | Display name. |
password_hash | TEXT | Yes | — | — | Password hash. Empty when the user signs in through a third-party provider and has not set a password. |
account_id | TEXT | Yes | — | — | Account ID returned by the sign-in provider. |
image_url | TEXT | Yes | — | — | Avatar URL. |
blog_url | TEXT | Yes | — | — | User homepage or blog URL. |
provider | TEXT | No | 'email' | — | Account sign-in provider. |
two_factor_enabled | INTEGER | No | 0 | — | Whether two-factor authentication is enabled. 1 means enabled. |
totp_key | BLOB | Yes | — | — | Encrypted TOTP secret. |
recovery_codes | JSON | No | '[]' | — | Array of recovery code hashes. |
recovery_codes_generated_at | INTEGER | No | 0 | — | Most recent recovery code generation time, in Unix milliseconds. |
deleted_at | INTEGER | No | 0 | — | Soft deletion time. 0 means not deleted. |
deleted_reason | TEXT | Yes | — | — | Reason for soft deletion. |
disabled_at | INTEGER | No | 0 | — | Disable time. 0 means not disabled. |
disabled_reason | TEXT | Yes | — | — | Reason for disabling. |
disabled_expires_at | INTEGER | No | 0 | — | End time of a temporary suspension. 0 means no end time is set. |
invited_by_id | INTEGER | Yes | — | — | User ID of the affiliate who invited this user. |
own_referral_code | TEXT | No | — | — | Unique referral code assigned to this user. |
affiliate_enabled_at | INTEGER | No | 0 | — | Time affiliate participation was enabled. 0 means not enabled. |
affiliate_disabled_at | INTEGER | No | 0 | — | Time affiliate participation was disabled. 0 means not disabled. |
affiliate_disabled_reason | TEXT | Yes | — | — | Reason for disabling affiliate participation. |
affiliate_disabled_by_id | INTEGER | Yes | — | — | ID of the admin user who disabled it. |
referral_status | TEXT | Yes | — | — | Referral eligibility status. |
referral_status_reason | TEXT | Yes | — | — | Reason for the referral eligibility status change. |
referral_status_changed_at | INTEGER | No | 0 | — | Most recent referral eligibility status change time. 0 means not yet recorded. |
referral_status_changed_by_id | INTEGER | Yes | — | — | ID of the admin user who changed the referral eligibility status. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | Current Unix time in milliseconds | — | Last update time, in Unix milliseconds. |
notification
Stores in-app notification content, audience, publication status, and counts.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
audience_type | TEXT | No | — | — | Notification audience type: all users or selected users. |
recipient_count | INTEGER | No | 0 | — | Number of target users. |
read_count | INTEGER | No | 0 | — | Number of users who have read the notification. |
title | TEXT | No | — | — | Title. |
summary | TEXT | No | — | — | Summary. |
message | JSON | No | — | — | Structured notification content. |
status | TEXT | No | — | — | Current status. |
created_by_user_id | INTEGER | Yes | — | — | ID of the admin user who created this record. |
published_at | INTEGER | Yes | — | — | Notification publication time, in Unix milliseconds. |
expires_at | INTEGER | Yes | — | — | Expiration time, in Unix milliseconds. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
user_notification
Stores each user's read and dismissal status for a notification, along with a concurrency control marker for updating the read count.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
user_id | INTEGER | No | — | PK (composite) | User ID. |
notification_id | TEXT | No | — | PK (composite) | Notification ID. |
read_at | INTEGER | Yes | — | — | Time the user read the notification, in Unix milliseconds. |
dismissed_at | INTEGER | Yes | — | — | Time the user dismissed the notification, in Unix milliseconds. |
read_claim_id | TEXT | Yes | — | — | Unique identifier used for concurrent updates to the read count. |
affiliate_payout_profiles
Stores encrypted affiliate payout details.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
user_id | INTEGER | No | — | — | User ID. |
payment_method | TEXT | No | — | — | Payout method. |
encrypted_details | BLOB | No | — | — | Encrypted payout details. |
payment_account_fingerprint | TEXT | No | — | — | Payout account fingerprint used to detect duplicate details. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
affiliate_commissions
Stores the source, calculation snapshot, and validity status of each referral commission.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
affiliate_user_id | INTEGER | No | — | — | User ID of the affiliate receiving the commission or settlement payment. |
referred_user_id | INTEGER | No | — | — | ID of the user who signed up or purchased through a referral. |
product_id | TEXT | No | — | — | Product key from config/products.ts. |
plan_id | TEXT | No | — | — | Plan key from config/products.ts. |
provider | TEXT | No | — | — | Payment provider that generated the commission. |
connection_id | TEXT | No | — | — | Payment connection ID from config/payment.ts. |
transaction_id | TEXT | No | — | — | Transaction ID. |
transaction_item_id | TEXT | No | — | — | Transaction line item ID. |
provider_line_item_id | TEXT | No | — | — | Line item ID in the payment provider. |
provider_price_id | TEXT | Yes | — | — | Price ID in the payment provider. |
transaction_status | TEXT | No | — | — | Transaction status recorded when the commission was generated. |
payment_kind | TEXT | No | — | — | Payment type: one-time or subscription payment. |
subscription_id | TEXT | Yes | — | — | Subscription ID. |
quantity | INTEGER | Yes | — | — | Quantity. |
unit_amount_minor | INTEGER | Yes | — | — | Unit price, in the currency's smallest unit. |
unit_amount_decimal | TEXT | Yes | — | — | High-precision unit price string returned by the payment provider. |
subtotal_minor | INTEGER | Yes | — | — | Subtotal before discounts and taxes, in the currency's smallest unit. |
discount_minor | INTEGER | Yes | — | — | Discount amount, in the currency's smallest unit. |
tax_minor | INTEGER | Yes | — | — | Tax amount, in the currency's smallest unit. |
total_minor | INTEGER | No | — | — | Total amount, in the currency's smallest unit. |
currency | TEXT | No | — | — | Currency code. |
calculation_type | TEXT | No | — | — | Commission calculation method: fixed amount or percentage. |
percentage_basis_points | INTEGER | Yes | — | — | Commission rate in basis points. 10000 means 100%. |
percentage_base | TEXT | Yes | — | — | Amount basis used to calculate percentage commissions. |
fixed_amount_minor | INTEGER | Yes | — | — | Fixed commission amount, in the currency's smallest unit. |
fixed_currency | TEXT | Yes | — | — | Currency for fixed commissions. |
status | TEXT | No | 'valid' | — | Current status. |
status_reason_code | TEXT | Yes | — | — | Reason code for commission invalidation or refund. |
status_reason | TEXT | Yes | — | — | Reason supplied when using a custom reason code. |
status_internal_note | TEXT | Yes | — | — | Status note visible only in the admin dashboard. |
status_changed_at | INTEGER | No | 0 | — | Most recent status change time. 0 means not yet recorded. |
status_changed_by_id | INTEGER | Yes | — | — | ID of the admin user who changed the status. |
earned_at | INTEGER | Yes | — | — | Commission confirmation time, in Unix milliseconds. |
available_at | INTEGER | Yes | — | — | Time the commission became available for settlement, in Unix milliseconds. |
deleted_at | INTEGER | No | 0 | — | Soft deletion time. 0 means not deleted. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
affiliate_monthly_payouts
Aggregates commissions and payment status by affiliate, month, and currency.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
affiliate_user_id | INTEGER | No | — | — | User ID of the affiliate receiving the commission or settlement payment. |
period_start | INTEGER | No | — | — | Start of the settlement month, in Unix milliseconds. |
currency | TEXT | No | — | — | Currency code. |
calculated_referred_user_count | INTEGER | No | 0 | — | Number of referred users included in this period's settlement. |
calculated_commission_count | INTEGER | No | 0 | — | Total number of commission records for this period. |
calculated_valid_count | INTEGER | No | 0 | — | Number of valid commission records for this period. |
calculated_refunded_count | INTEGER | No | 0 | — | Number of refunded commission records for this period. |
calculated_invalid_count | INTEGER | No | 0 | — | Number of invalid commission records for this period. |
calculated_total_payment_amount_minor | INTEGER | No | 0 | — | Total payment amount for this period, in the currency's smallest unit. |
calculated_valid_payment_amount_minor | INTEGER | No | 0 | — | Payment amount that generated valid commissions, in the currency's smallest unit. |
calculated_valid_commission_amount_minor | INTEGER | No | 0 | — | Valid commission amount for this period, in the currency's smallest unit. |
calculated_refunded_commission_amount_minor | INTEGER | No | 0 | — | Refunded commission amount for this period, in the currency's smallest unit. |
calculated_invalid_commission_amount_minor | INTEGER | No | 0 | — | Invalid commission amount for this period, in the currency's smallest unit. |
calculation_changed_at | INTEGER | No | 0 | — | Most recent settlement amount change time. |
status | TEXT | No | 'draft' | — | Current status. |
requested_at | INTEGER | No | 0 | — | Time the settlement request was submitted. 0 means not yet requested. |
actual_paid_amount_minor | INTEGER | Yes | — | — | Actual amount paid, in the currency's smallest unit. |
paid_at | INTEGER | No | 0 | — | Actual payment time for the monthly settlement. 0 means not yet paid. |
paid_by_id | INTEGER | Yes | — | — | ID of the admin user who recorded the payment. |
email_content_json | JSON | Yes | — | — | Content snapshot of the settlement notification email. |
send_email | INTEGER | No | 0 | — | Whether to send a settlement notification email. 1 means send. |
email_sent_at | INTEGER | No | 0 | — | Time the settlement notification email was sent successfully. 0 means not yet sent. |
email_failure_reason | TEXT | Yes | — | — | Reason the settlement notification email failed to send. |
manual_updated_at | INTEGER | No | 0 | — | Time the settlement record was manually edited in the admin dashboard. 0 means not edited. |
manual_updated_by_id | INTEGER | Yes | — | — | ID of the admin user who made the manual edit. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
affiliate_monthly_payout_records
Stores each actual payment for a monthly settlement, along with a snapshot of the payout details.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
monthly_payout_id | INTEGER | No | — | — | Monthly settlement record ID. |
revision | INTEGER | No | — | — | Payment record version within the same monthly settlement. |
calculated_amount_minor | INTEGER | No | — | — | Amount due calculated when the payment was recorded, in the currency's smallest unit. |
calculation_changed_at | INTEGER | No | — | — | Most recent settlement amount change time. |
actual_paid_amount_minor | INTEGER | No | — | — | Actual amount paid, in the currency's smallest unit. |
difference_reason | TEXT | No | '' | — | Reason the actual payment differs from the calculated amount. |
internal_note | TEXT | No | '' | — | Note visible only in the admin dashboard. |
paid_at | INTEGER | No | — | — | Time this payment actually occurred, in Unix milliseconds. |
encrypted_payout_profile | BLOB | No | — | — | Encrypted snapshot of the payout details used for the payment. |
saved_at | INTEGER | No | — | — | Time the payment record was saved, in Unix milliseconds. |
saved_by_id | INTEGER | No | — | — | ID of the admin user who saved the payment record. |
saas_session
Stores user sign-in sessions, expiration times, and recent activity information.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
user_id | INTEGER | No | — | — | User ID. |
expires_at | INTEGER | No | — | — | Expiration time, in Unix milliseconds. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
last_seen_at | INTEGER | No | Current Unix time in milliseconds | — | Most recent activity time, in Unix milliseconds. |
ip | TEXT | Yes | — | — | IP address. |
user_agent | TEXT | Yes | — | — | User-Agent. |
country | TEXT | Yes | — | — | Country or region code. |
two_factor_verified | INTEGER | No | 0 | — | Whether two-factor authentication has been completed in the current flow. 1 means verified. |
two_factor_setup_session
Stores temporary secrets and recovery codes while setting up or replacing two-factor authentication.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
user_id | INTEGER | No | — | FK → saas_user.id (cascade delete) | User ID. |
saas_session_id | TEXT | No | — | FK → saas_session.id (cascade delete) | Sign-in session ID. |
purpose | TEXT | No | — | — | Purpose of this temporary session. |
encrypted_totp_key | BLOB | No | — | — | TOTP secret stored encrypted during setup. |
recovery_codes | JSON | No | — | — | Array of recovery code hashes. |
encrypted_recovery_codes | BLOB | No | — | — | Recovery codes stored encrypted during setup. |
attempt_count | INTEGER | No | 0 | — | Number of verification attempts made. |
claimed_at | INTEGER | No | 0 | — | Time processing rights to this temporary record were claimed. 0 means not yet processed. |
consumed_at | INTEGER | No | 0 | — | Time this temporary record was consumed. 0 means not yet used. |
expires_at | INTEGER | No | — | — | Expiration time, in Unix milliseconds. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
email_verification_session
Stores verification codes and expiration times for the email verification flow.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
user_id | INTEGER | No | — | — | User ID. |
email | TEXT | No | — | — | Email address. |
code | TEXT | No | — | — | Verification code or authorization code. |
type | TEXT | No | — | — | Record type. |
attempt_count | INTEGER | No | 0 | — | Number of verification attempts made. |
expires_at | INTEGER | No | — | — | Expiration time, in Unix milliseconds. |
password_reset_session
Stores verification codes, verification status, and expiration times for the password reset flow.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
user_id | INTEGER | No | — | — | User ID. |
email | TEXT | No | — | — | Email address. |
code | TEXT | No | — | — | Verification code or authorization code. |
type | TEXT | Yes | — | — | Record type. |
attempt_count | INTEGER | No | 0 | — | Number of verification attempts made. |
expires_at | INTEGER | No | — | — | Expiration time, in Unix milliseconds. |
email_verified | INTEGER | No | 0 | — | Whether the email address has been verified. 1 means verified. |
two_factor_verified | INTEGER | No | 0 | — | Whether two-factor authentication has been completed in the current flow. 1 means verified. |
oauth_auth_session
Stores the temporary state of an OAuth 2.0 authorization request before the user approves it.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
user_id | INTEGER | Yes | — | — | User ID. |
client_id | TEXT | No | — | — | OAuth 2.0 client ID. |
redirect_uri | TEXT | No | — | — | Redirect URI used for this authorization request. |
response_type | TEXT | No | — | — | OAuth 2.0 response type. |
scope | TEXT | Yes | — | — | Scope string for this authorization request. |
state | TEXT | Yes | — | — | OAuth 2.0 state, used to correlate authorization requests and prevent CSRF. |
code_challenge | TEXT | Yes | — | — | PKCE code challenge. |
code_challenge_method | TEXT | Yes | — | — | PKCE code challenge method. |
approved_at | INTEGER | Yes | NULL | — | Time the user approved authorization. |
upgrade_details | JSON | Yes | NULL | — | Upgrade suggestion data used during authorization. |
expires_at | INTEGER | No | — | — | Expiration time, in Unix milliseconds. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
oauth_client
Stores OAuth 2.0 clients, redirect URIs, grant types, and scopes.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
name | TEXT | No | — | — | Name. |
secret | TEXT | Yes | — | — | Hash of the OAuth 2.0 client secret. May be empty for public clients. |
owner_user_id | INTEGER | Yes | NULL | — | User ID of the OAuth 2.0 client's owner. |
redirect_uris | JSON | No | '[]' | — | Array of redirect URIs allowed for the client. |
allowed_grants | JSON | No | '[]' | — | Array of grant types allowed for the client. |
scopes | JSON | No | '[]' | — | Array of scopes. |
logo_uri | TEXT | Yes | — | — | Client logo URL. |
homepage_uri | TEXT | Yes | — | — | Client homepage URL. |
description | TEXT | Yes | — | — | Description text. |
privacy_policy_uri | TEXT | Yes | — | — | Privacy policy URL. |
terms_of_service_uri | TEXT | Yes | — | — | Terms of service URL. |
disabled_at | INTEGER | No | 0 | — | Disable time. 0 means not disabled. |
deleted_at | INTEGER | No | 0 | — | Soft deletion time. 0 means not deleted. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | Current Unix time in milliseconds | — | Last update time, in Unix milliseconds. |
oauth_auth_code
Stores OAuth 2.0 authorization codes and PKCE information.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
code | TEXT | No | — | PK | Verification code or authorization code. |
redirect_uri | TEXT | Yes | — | — | Redirect URI used for this authorization request. |
code_challenge | TEXT | Yes | — | — | PKCE code challenge. |
code_challenge_method | TEXT | Yes | 'plain' | — | PKCE code challenge method. |
expires_at | INTEGER | No | — | — | Expiration time, in Unix milliseconds. |
user_id | INTEGER | Yes | NULL | — | User ID. |
client_id | TEXT | No | — | — | OAuth 2.0 client ID. |
scopes | JSON | No | '[]' | — | Array of scopes. |
revoked_at | INTEGER | No | 0 | — | Revocation time. 0 means not revoked. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | Current Unix time in milliseconds | — | Last update time, in Unix milliseconds. |
oauth_token
Stores OAuth 2.0 access tokens and refresh tokens.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
access_token | TEXT | No | — | PK | Access token, also the table's primary key. |
access_token_expires_at | INTEGER | No | — | — | Access token expiration time, in Unix milliseconds. |
refresh_token | TEXT | Yes | — | — | Refresh token. |
refresh_token_expires_at | INTEGER | Yes | NULL | — | Refresh token expiration time, in Unix milliseconds. |
client_id | TEXT | No | — | — | OAuth 2.0 client ID. |
user_id | INTEGER | Yes | NULL | — | User ID. |
oauth_code | TEXT | Yes | NULL | — | Authorization code used to issue this token. |
scopes | JSON | No | '[]' | — | Array of scopes. |
revoked_at | INTEGER | No | 0 | — | Revocation time. 0 means not revoked. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | Current Unix time in milliseconds | — | Last update time, in Unix milliseconds. |
user_role_capability
Stores the static capabilities assigned to a subject by expanding a role grant.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
subject_type | TEXT | No | — | — | Subject type. |
subject_id | TEXT | No | — | — | Subject ID. |
user_id | INTEGER | Yes | — | — | User ID. |
event_id | TEXT | Yes | — | — | ID of the Reaction Event that granted this role capability. |
command_id | TEXT | Yes | — | — | ID of the Reaction Command that granted this role capability. |
source_type | TEXT | No | — | — | Type of the role grant source. |
source_key | TEXT | No | — | — | Source key for the role or entitlement. |
role_key | TEXT | No | — | — | Role key from config/roles.ts. |
capability_key | TEXT | No | — | — | Capability key from config/capability.ts. |
starts_at | INTEGER | Yes | NULL | — | Effective start time, in Unix milliseconds. |
ends_at | INTEGER | Yes | NULL | — | End time, in Unix milliseconds. |
metadata | JSON | Yes | — | — | Application metadata. |
deleted_at | INTEGER | No | 0 | — | Soft deletion time. 0 means not deleted. |
disabled_at | INTEGER | No | 0 | — | Disable time. 0 means not disabled. |
disabled_reason | TEXT | Yes | — | — | Reason for disabling. |
disabled_expires_at | INTEGER | No | 0 | — | End time of a temporary suspension. 0 means no end time is set. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | Current Unix time in milliseconds | — | Last update time, in Unix milliseconds. |
user_entitlement_capability
Stores the boolean or quota capabilities assigned to a subject by expanding an entitlement grant.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
subject_type | TEXT | No | — | — | Subject type. |
subject_id | TEXT | No | — | — | Subject ID. |
user_id | INTEGER | Yes | — | — | User ID. |
event_id | TEXT | Yes | — | — | ID of the Reaction Event that granted this entitlement capability. |
command_id | TEXT | Yes | — | — | ID of the Reaction Command that granted this entitlement capability. |
source_type | TEXT | No | — | — | Type of the entitlement grant source. |
source_key | TEXT | No | — | — | Source key for the role or entitlement. |
source_quantity | INTEGER | No | 1 | — | Quantity granted by the source. |
source_unit_limit | INTEGER | Yes | NULL | — | Quota provided by each source unit. |
entitlement_key | TEXT | No | — | — | Entitlement key from config/entitlements.ts. |
capability_key | TEXT | No | — | — | Capability key from config/capability.ts. |
capability_type | TEXT | No | — | — | Capability type. |
priority | INTEGER | No | 0 | — | Priority. Higher values indicate higher priority. |
rollover | INTEGER | No | 0 | — | Whether unused quota rolls over at the end of the cycle. 1 means rollover is enabled. |
quota_limit | INTEGER | No | 0 | — | Quota limit. |
quota_total | INTEGER | No | 0 | — | Total quota currently available. |
quota_used | INTEGER | No | 0 | — | Quota currently used. |
quota_used_reset_mode | TEXT | No | 'clear' | — | How used quota is handled when the reset cycle ends. |
starts_at | INTEGER | Yes | NULL | — | Effective start time, in Unix milliseconds. |
ends_at | INTEGER | Yes | NULL | — | End time, in Unix milliseconds. |
reset_alignment | TEXT | Yes | NULL | — | Quota cycle alignment. |
reset_interval | TEXT | Yes | NULL | — | Quota reset interval unit. |
reset_interval_count | INTEGER | No | 0 | — | Number of units in each quota cycle. |
anchor_at | INTEGER | No | — | — | Quota cycle anchor time, in Unix milliseconds. |
reset_period_count | INTEGER | Yes | 0 | — | Number of completed quota cycles. |
anchor_reset_at | INTEGER | Yes | — | — | Reset time for the current cycle, calculated from the anchor. |
metadata | JSON | Yes | — | — | Application metadata. |
deleted_at | INTEGER | No | 0 | — | Soft deletion time. 0 means not deleted. |
disabled_at | INTEGER | No | 0 | — | Disable time. 0 means not disabled. |
disabled_reason | TEXT | Yes | — | — | Reason for disabling. |
disabled_expires_at | INTEGER | No | 0 | — | End time of a temporary suspension. 0 means no end time is set. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | Current Unix time in milliseconds | — | Last update time, in Unix milliseconds. |
capability_quota_event
Stores quota capability additions, deductions, resets, and rollovers.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
subject_type | TEXT | No | — | — | Subject type. |
subject_id | TEXT | No | — | — | Subject ID. |
user_id | INTEGER | Yes | — | — | User ID. |
source_type | TEXT | No | — | — | Type of the source that generated the quota record. |
source_key | TEXT | No | — | — | Source key for the role or entitlement. |
entitlement_key | TEXT | No | — | — | Entitlement key from config/entitlements.ts. |
capability_key | TEXT | No | — | — | Capability key from config/capability.ts. |
event_type | TEXT | No | — | — | Quota change type, such as grant, usage, or reset. |
delta | INTEGER | No | — | — | Amount of this quota change. Positive values add quota, and negative values deduct it. |
reason | TEXT | Yes | — | — | Reason for this quota change. |
metadata | TEXT | Yes | — | — | Application metadata. |
created_at | INTEGER | No | Current Unix time in milliseconds | — | Creation time, in Unix milliseconds. |
event_execution
Stores Reaction Event input snapshots, idempotency keys, and execution leases.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
user_id | INTEGER | Yes | — | — | User ID. |
event_type | TEXT | No | — | — | Reaction Event type. |
event_version | INTEGER | No | — | — | Event definition version. |
idempotency_key | TEXT | No | — | — | Event idempotency key. |
continue_on_failure | INTEGER | No | — | — | Whether to continue with subsequent Commands after a Command reports a business failure. |
payload | TEXT | No | — | — | Serialized input data. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
lease_token | TEXT | Yes | — | — | Token for the current execution lease. |
lease_expires_at | INTEGER | Yes | — | — | Expiration time of the current execution lease. |
command_execution
Stores Commands generated by an Event, their execution order, retry counts, and results.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
event_execution_id | TEXT | No | — | FK → event_execution.id (cascade delete when the Event is deleted) | Parent Event execution record ID. |
user_id | INTEGER | Yes | — | — | User ID. |
command_key | TEXT | No | — | — | Command step name, unique within the same Event. |
command_type | TEXT | No | — | — | Command type. |
command_version | INTEGER | No | — | — | Command definition version. |
mode | TEXT | No | — | — | Command execution mode: sync or async. |
max_attempts | INTEGER | No | — | — | Maximum number of automatic executions allowed. |
sequence | INTEGER | No | — | — | Command execution order within the Event. |
payload | TEXT | No | — | — | Serialized input data. |
status | TEXT | No | — | — | Current status. |
attempt_count | INTEGER | No | 0 | — | Number of executions so far. |
result | TEXT | Yes | — | — | Serialized Command return value. |
last_error | TEXT | Yes | — | — | Error message from the most recent processing failure. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
completed_at | INTEGER | Yes | — | — | Completion time, in Unix milliseconds. |
webhook_events
Stores raw payment provider webhook requests, processing status, and failure information.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | INTEGER | No | — | PK | Record primary key. |
provider | TEXT | No | — | — | Payment provider that sent the webhook. |
connection_id | TEXT | No | — | — | Payment connection ID from config/payment.ts. |
event_id | TEXT | No | — | — | Webhook event ID supplied by the payment provider. |
event_type | TEXT | No | — | — | Webhook event type supplied by the payment provider. |
user_id | TEXT | Yes | — | — | User ID. |
occurred_at | INTEGER | Yes | — | — | Event occurrence time recorded by the payment provider, in Unix milliseconds. |
raw_body | TEXT | No | — | — | Raw webhook request body, used for signature verification and replay. |
status | TEXT | No | 'processing' | — | Current status. |
claim_token | TEXT | Yes | — | — | Token used for the webhook processing lease. |
last_error | TEXT | Yes | — | — | Error message from the most recent processing failure. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
payment_customers
Maps local users to payment provider Customers.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
user_id | TEXT | No | — | — | User ID. |
provider | TEXT | No | — | — | Payment provider the Customer belongs to. |
connection_id | TEXT | No | — | — | Payment connection ID from config/payment.ts. |
provider_customer_id | TEXT | No | — | — | Customer ID in the payment provider. |
is_primary | INTEGER | No | 0 | — | Whether this is the user's primary Customer for this payment connection. 1 means yes. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
checkout_sessions
Stores local Checkout Sessions and the status returned by the payment provider.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
provider | TEXT | No | — | — | Payment provider the Checkout belongs to. |
connection_id | TEXT | No | — | — | Payment connection ID from config/payment.ts. |
provider_checkout_type | TEXT | No | — | — | Checkout type in the payment provider. |
provider_checkout_id | TEXT | Yes | — | — | Checkout ID in the payment provider. |
customer_id | TEXT | No | — | FK → payment_customers.id | payment_customers record ID. |
mode | TEXT | No | — | — | Checkout mode: one-time payment or subscription. |
status | TEXT | No | — | — | Current status. |
provider_status | TEXT | Yes | — | — | Original status returned by the payment provider. |
payment_status | TEXT | No | 'pending' | — | Payment status. |
provider_payment_status | TEXT | Yes | — | — | Original payment status returned by the payment provider. |
has_invoice_creation | INTEGER | No | 0 | — | Whether the payment provider is requested to create an invoice. 1 means yes. |
checkout_request | JSON | Yes | — | — | Snapshot of the request used to create the Checkout. |
context | JSON | Yes | — | — | Application context saved when the Checkout was created. |
metadata | JSON | Yes | — | — | Application metadata. |
currency | TEXT | Yes | — | — | Currency code. |
amount_total_minor | INTEGER | Yes | — | — | Total Checkout amount, in the currency's smallest unit. |
provider_data | JSON | Yes | — | — | Original data returned by the payment provider. |
last_error | TEXT | Yes | — | — | Error message from the most recent processing failure. |
provider_updated_at | INTEGER | Yes | — | — | Last update time in the payment provider, in Unix milliseconds. |
expires_at | INTEGER | Yes | — | — | Expiration time, in Unix milliseconds. |
completed_at | INTEGER | Yes | — | — | Completion time, in Unix milliseconds. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
purchase_items
Stores one-time purchase items in a Checkout Session.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
checkout_session_id | TEXT | No | — | FK → checkout_sessions.id (cascade delete) | checkout_sessions record ID. |
provider_line_item_id | TEXT | Yes | — | — | Line item ID in the payment provider. |
provider_product_id | TEXT | Yes | — | — | Product ID in the payment provider. |
provider_price_id | TEXT | Yes | — | — | Price ID in the payment provider. |
provider_variant_id | TEXT | Yes | — | — | Variant ID in the payment provider. |
description | TEXT | Yes | — | — | Description text. |
quantity | INTEGER | Yes | — | — | Quantity. |
metadata | JSON | Yes | — | — | Application metadata. |
provider_data | JSON | Yes | — | — | Original data returned by the payment provider. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
subscriptions
Stores payment provider subscriptions and their billing periods, pauses, cancellations, and amounts.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
customer_id | TEXT | No | — | — | payment_customers record ID. |
checkout_session_id | TEXT | Yes | — | — | checkout_sessions record ID. |
provider | TEXT | No | — | — | Payment provider the subscription belongs to. |
connection_id | TEXT | No | — | — | Payment connection ID from config/payment.ts. |
provider_subscription_id | TEXT | No | — | — | Subscription ID in the payment provider. |
status | TEXT | No | — | — | Current status. |
provider_status | TEXT | Yes | — | — | Original status returned by the payment provider. |
collection_mode | TEXT | No | 'unknown' | — | Subscription payment collection method. |
collection_paused | INTEGER | No | 0 | — | Whether payment collection is paused for the subscription. 1 means paused. |
collection_pause_resumes_at | INTEGER | Yes | — | — | Scheduled time to resume payment collection. |
collection_pause_details | JSON | Yes | — | — | Payment collection pause details returned by the payment provider. |
started_at | INTEGER | Yes | — | — | Subscription start time, in Unix milliseconds. |
trial_start | INTEGER | Yes | — | — | Trial start time, in Unix milliseconds. |
trial_end | INTEGER | Yes | — | — | Trial end time, in Unix milliseconds. |
current_period_start | INTEGER | Yes | — | — | Start of the current billing period, in Unix milliseconds. |
current_period_end | INTEGER | Yes | — | — | End of the current billing period, in Unix milliseconds. |
cancel_at_period_end | INTEGER | No | 0 | — | Whether to cancel at the end of the current billing period. 1 means yes. |
cancel_at | INTEGER | Yes | — | — | Scheduled cancellation time, in Unix milliseconds. |
canceled_at | INTEGER | Yes | — | — | Cancellation time, in Unix milliseconds. |
paused_at | INTEGER | Yes | — | — | Pause time, in Unix milliseconds. |
ends_at | INTEGER | Yes | — | — | Expected subscription end time supplied by the payment provider, in Unix milliseconds. |
ended_at | INTEGER | Yes | — | — | Subscription end time, in Unix milliseconds. |
scheduled_change | JSON | Yes | — | — | Scheduled subscription change returned by the payment provider. |
scheduled_change_at | INTEGER | Yes | — | — | Time the scheduled change takes effect. |
next_billed_at | INTEGER | Yes | — | — | Next charge time, in Unix milliseconds. |
next_amount_minor | INTEGER | Yes | — | — | Amount due for the next period, in the currency's smallest unit. |
next_currency | TEXT | Yes | — | — | Payment currency for the next period. |
metadata | JSON | Yes | — | — | Application metadata. |
provider_data | JSON | Yes | — | — | Original data returned by the payment provider. |
provider_updated_at | INTEGER | Yes | — | — | Last update time in the payment provider, in Unix milliseconds. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
subscription_items
Stores subscription products, Prices, quantities, and billing periods.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
subscription_id | TEXT | No | — | FK → subscriptions.id (cascade delete) | Subscription ID. |
provider_subscription_item_id | TEXT | Yes | — | — | Subscription Item ID in the payment provider. |
provider_product_id | TEXT | Yes | — | — | Product ID in the payment provider. |
provider_price_id | TEXT | Yes | — | — | Price ID in the payment provider. |
description | TEXT | Yes | — | — | Description text. |
quantity | INTEGER | Yes | — | — | Quantity. |
unit_amount_minor | INTEGER | Yes | — | — | Unit price, in the currency's smallest unit. |
currency | TEXT | Yes | — | — | Currency code. |
pricing_model | TEXT | No | 'unknown' | — | Pricing model. |
billing_interval | TEXT | Yes | — | — | Billing interval unit. |
billing_interval_count | INTEGER | Yes | — | — | Number of units in a billing period. |
current_period_start | INTEGER | Yes | — | — | Start of the current billing period, in Unix milliseconds. |
current_period_end | INTEGER | Yes | — | — | End of the current billing period, in Unix milliseconds. |
metadata | JSON | Yes | — | — | Application metadata. |
provider_data | JSON | Yes | — | — | Original data returned by the payment provider. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
transactions
Stores payment transactions, invoice amounts, payer details, and invoice information.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
public_reference_id | TEXT | No | — | — | Transaction reference number that can be shown to users. |
provider | TEXT | No | — | — | Payment provider the transaction belongs to. |
connection_id | TEXT | No | — | — | Payment connection ID from config/payment.ts. |
source_type | TEXT | No | — | — | Type of the original transaction object in the payment provider. |
provider_source_id | TEXT | No | — | — | ID of the original transaction object in the payment provider. |
customer_id | TEXT | Yes | — | — | payment_customers record ID. |
checkout_session_id | TEXT | Yes | — | — | checkout_sessions record ID. |
provider_customer_id | TEXT | Yes | — | — | Customer ID in the payment provider. |
provider_subscription_id | TEXT | Yes | — | — | Subscription ID in the payment provider. |
kind | TEXT | No | — | — | Transaction type, such as a one-time payment, initial subscription payment, or subscription renewal. |
status | TEXT | No | — | — | Current status. |
provider_status | TEXT | Yes | — | — | Original status returned by the payment provider. |
collection_mode | TEXT | No | 'unknown' | — | Subscription payment collection method. |
subtotal_minor | INTEGER | Yes | — | — | Subtotal before discounts and taxes, in the currency's smallest unit. |
discount_minor | INTEGER | Yes | — | — | Discount amount, in the currency's smallest unit. |
tax_minor | INTEGER | Yes | — | — | Tax amount, in the currency's smallest unit. |
total_minor | INTEGER | No | — | — | Total amount, in the currency's smallest unit. |
amount_due_minor | INTEGER | Yes | — | — | Amount due, in the currency's smallest unit. |
amount_paid_minor | INTEGER | Yes | — | — | Amount paid, in the currency's smallest unit. |
amount_remaining_minor | INTEGER | Yes | — | — | Unpaid amount, in the currency's smallest unit. |
currency | TEXT | No | — | — | Currency code. |
billing_reason | TEXT | Yes | — | — | Billing reason that generated this transaction. |
payer_email | TEXT | Yes | — | — | Payer email address. |
payer_name | TEXT | Yes | — | — | Payer name. |
billing_address | JSON | Yes | — | — | Billing address. |
tax_identifiers | JSON | Yes | — | — | Array of tax identifiers. |
invoice_number | TEXT | Yes | — | — | Invoice number. |
document_url | TEXT | Yes | — | — | Invoice document URL supplied by the payment provider. |
document_pdf_url | TEXT | Yes | — | — | PDF invoice URL supplied by the payment provider. |
failure_code | TEXT | Yes | — | — | Failure code returned by the payment provider. |
failure_reason | TEXT | Yes | — | — | Reason for the processing failure. |
metadata | JSON | Yes | — | — | Application metadata. |
provider_data | JSON | Yes | — | — | Original data returned by the payment provider. |
provider_updated_at | INTEGER | Yes | — | — | Last update time in the payment provider, in Unix milliseconds. |
issued_at | INTEGER | Yes | — | — | Invoice or transaction issue time, in Unix milliseconds. |
due_at | INTEGER | Yes | — | — | Payment due time, in Unix milliseconds. |
paid_at | INTEGER | Yes | — | — | Time payment for the transaction was completed, in Unix milliseconds. |
occurred_at | INTEGER | No | — | — | Time the transaction actually occurred, in Unix milliseconds. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
transaction_items
Stores transaction products, Prices, billing periods, and amount breakdowns.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
transaction_id | TEXT | No | — | FK → transactions.id (cascade delete) | Transaction ID. |
provider_line_item_id | TEXT | Yes | — | — | Line item ID in the payment provider. |
provider_product_id | TEXT | Yes | — | — | Product ID in the payment provider. |
provider_price_id | TEXT | Yes | — | — | Price ID in the payment provider. |
provider_variant_id | TEXT | Yes | — | — | Variant ID in the payment provider. |
provider_subscription_item_id | TEXT | Yes | — | — | Subscription Item ID in the payment provider. |
description | TEXT | Yes | — | — | Description text. |
billing_type | TEXT | No | 'unknown' | — | Billing type of the transaction line item. |
is_proration | INTEGER | No | 0 | — | Whether this line item is a proration adjustment. 1 means yes. |
billing_interval | TEXT | Yes | — | — | Billing interval unit. |
billing_interval_count | INTEGER | Yes | — | — | Number of units in a billing period. |
period_start | INTEGER | Yes | — | — | Start of the billing period for this line item, in Unix milliseconds. |
period_end | INTEGER | Yes | — | — | End of the billing period for this line item, in Unix milliseconds. |
quantity | INTEGER | Yes | — | — | Quantity. |
unit_amount_minor | INTEGER | Yes | — | — | Unit price, in the currency's smallest unit. |
unit_amount_decimal | TEXT | Yes | — | — | High-precision unit price string returned by the payment provider. |
subtotal_minor | INTEGER | Yes | — | — | Subtotal before discounts and taxes, in the currency's smallest unit. |
discount_minor | INTEGER | Yes | — | — | Discount amount, in the currency's smallest unit. |
tax_minor | INTEGER | Yes | — | — | Tax amount, in the currency's smallest unit. |
total_minor | INTEGER | No | — | — | Total amount, in the currency's smallest unit. |
currency | TEXT | No | — | — | Currency code. |
metadata | JSON | Yes | — | — | Application metadata. |
provider_data | JSON | Yes | — | — | Original data returned by the payment provider. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |
refunds
Stores transaction refunds and the refund status returned by the payment provider.
| Field | Type | Nullable | Default | Key | Description |
|---|---|---|---|---|---|
id | TEXT | No | — | PK | Record primary key. |
transaction_id | TEXT | No | — | FK → transactions.id (prevents deletion of transactions that still have refunds) | Transaction ID. |
provider | TEXT | No | — | — | Payment provider the refund belongs to. |
connection_id | TEXT | No | — | — | Payment connection ID from config/payment.ts. |
provider_refund_type | TEXT | No | — | — | Refund type in the payment provider. |
provider_refund_id | TEXT | No | — | — | Refund ID in the payment provider. |
provider_parent_type | TEXT | Yes | — | — | Refund parent object type in the payment provider. |
provider_parent_id | TEXT | Yes | — | — | Refund parent object ID in the payment provider. |
status | TEXT | No | — | — | Current status. |
provider_status | TEXT | Yes | — | — | Original status returned by the payment provider. |
amount_minor | INTEGER | No | — | — | Amount, in the currency's smallest unit. |
tax_amount_minor | INTEGER | Yes | — | — | Tax amount included in the refund, in the currency's smallest unit. |
currency | TEXT | No | — | — | Currency code. |
reason | TEXT | Yes | — | — | Refund reason supplied by the payment provider. |
failure_reason | TEXT | Yes | — | — | Reason for the processing failure. |
metadata | JSON | Yes | — | — | Application metadata. |
provider_data | JSON | Yes | — | — | Original data returned by the payment provider. |
provider_updated_at | INTEGER | No | — | — | Last update time in the payment provider, in Unix milliseconds. |
occurred_at | INTEGER | No | — | — | Time the refund actually occurred, in Unix milliseconds. |
created_at | INTEGER | No | — | — | Creation time, in Unix milliseconds. |
updated_at | INTEGER | No | — | — | Last update time, in Unix milliseconds. |