Billing
Tiers are platform-global priced offerings; licenses, payers, subscriptions and seats record what an organization bought and how each server is entitled.
Tables in this group: allowance, license, payer, seat, subscription, ticket, tier.
allowance
Self-hosted entitlement grant: at most one row per organization giving quantity free units at the custom SX tier so assignment runs with no subscription.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
organization_id | uuid | yes | Organization holding the grant; unique (uniq_allowance_organization), so an organization has zero or one row. |
tier_id | uuid | yes | Always the SX custom-rung tier row (ensureCustomTierRow), stored rather than looked up by label so entitlement reads on the ingest path add no query. |
quantity | integer | yes | Free SX units the self-hosted runtime grants to match its active licenses; always at least 1 because writing zero deletes the row instead. |
license
Organization-scoped server registration key: one row per minted key, latched to one server on first enroll, soft-deleted via revoked_at; may name a tier.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
organization_id | uuid | yes | Parent organization row (on delete cascade). |
server_id | uuid | no | Server that consumed this key, set once on first successful enroll (partial unique index: one license per server); null while unconsumed, SET NULL on delete. |
tier_id | uuid | no | Tier a manager chose in Add Server (hosted); holds a seat there until a server enrolls with this key and takes it. NULL when no tier was chosen. |
name | text | no | Optional operator display name; this server is reserved for the colocated control-plane license minted at install and refused by POST /licenses. |
token | text | no | Argon2id PHC hash of the registration key; NULL once the key binds to a server and for a key minted behind a ticket, and a NULL token verifies nothing. |
revoked_at | timestamp(3) with time zone | no | Soft-delete timestamp set by a revoke or by an ended subscription revoking every license; non-null means inactive, and the row keeps server_id for audit. |
expires_at | timestamp(3) with time zone | no | Set at mint to 7 days later: past it an unused key cannot enroll and holds no license; ignored once bound. NULL (the colocated key) never expires. |
payer
Projection of one provider customer (who pays), written only by the Stripe webhook ingress; its subject is exactly one of an organization or a user.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
organization_id | uuid | no | Organization subject; exactly one of organization_id and user_id is non-null (payer_subject_check), and it is unique per provider when set. |
user_id | uuid | no | User subject for a personal subscription; exactly one of organization_id and user_id is non-null (payer_subject_check), unique per provider when set. |
provider | text | yes | Payment provider that owns this customer; only stripe is allowed today (CHECK payer_provider_check), apple is reserved in comments but not accepted. |
provider_customer_id | text | yes | Provider-side customer id (Stripe cus_...); unique together with provider and the conflict target of the webhook upsert. |
tax_id | text | no | Value of the first tax id the provider reports on the customer (customer.tax_ids), copied by the webhook for display; presence only, never validated here. |
seat
Subscription line: quantity purchased licenses at one tier, projected from provider subscription items by the Stripe webhook (export subscriptionItem).
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
subscription_id | uuid | yes | Parent subscription row (on delete cascade). |
tier_id | uuid | yes | Tier this line counts against, resolved from the item product via tier.provider_product_id; unique per subscription, RESTRICT so a used tier stays readable. |
provider_item_id | text | yes | Provider-side subscription item id (Stripe si_...), unique; when two provider items map to one tier the row keeps the first id with the summed quantity. |
provider_price_id | text | yes | Provider price the item bills at (Stripe price_...), projected from the item and restated by every mutation; the tier knows its product, not its price. |
quantity | integer | yes | Number of licenses purchased at this tier, copied from the provider item quantity (summed when items share a tier); an ended subscription counts as zero. |
subscription
One provider subscription per payer, upserted by the Stripe webhook on provider_subscription_id; holds status, period end, parked schedule and grace clock.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
payer_id | uuid | yes | Parent payer row (on delete cascade). |
status | text | yes | Checked status: incomplete, incomplete_expired, trialing, active, past_due, canceled, unpaid, paused, or unknown for an unrecognised value. |
provider_subscription_id | text | yes | Provider-side subscription id (Stripe sub_...); unique and the conflict target of the webhook upsert. |
provider_status | text | yes | Provider status string verbatim, never interpreted; kept beside status so an unknown Stripe value lands as unknown plus the raw string, not a refused event. |
current_period_end | timestamp(3) with time zone | no | End of the current billing period as the provider reports it, taken from the subscription or else its first item; null when the provider gives none. |
schedule_id | text | no | Provider subscription schedule id (Stripe sub_sched_...) while a downgrade is parked on a schedule; null otherwise, written by the webhook projection. |
grace_expires_at | timestamp(3) with time zone | no | Always null since the TurboPanel grace clock was removed: provider retries now end a past-due subscription. Kept by the schema freeze, never read. |
past_due_since | timestamp(3) with time zone | no | First moment the provider reported past_due or unpaid; latched while delinquent, cleared by any other status so a later lapse is measured afresh. |
ticket
One-hour, single-use enrolment ticket: a join ticket (license_id set) stands in for a key at install, a re-enroll ticket (server_id set) re-keys one server.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
organization_id | uuid | yes | Parent organization row (on delete cascade). |
license_id | uuid | no | Registration key a join ticket binds when its server enrolls; null for a re-enroll ticket, CASCADE on delete. |
server_id | uuid | no | The one server a re-enroll ticket is bound to; null for a join ticket. Presented for any other server it is refused. |
used_by_server_id | uuid | no | Server the spent ticket produced or re-keyed, SET NULL on delete. |
created_by_user_id | uuid | no | User who issued the ticket, SET NULL on delete. |
server_name | text | no | Display name chosen in Add Server for a join ticket; informational. |
token | text | yes | Argon2id PHC hash of the ticket secret; the plaintext is returned once at mint and cannot be recovered from this row. |
expires_at | timestamp(3) with time zone | yes | Mint time plus one hour; past it the ticket is refused. |
used_at | timestamp(3) with time zone | no | Set atomically when the ticket is spent (or when an owner revokes it); a non-null value means it can never be used again. |
tier
Global billed offering: one row per ladder label (S1 to S7, SX) bound to a provider product; written under Admin Tiers, deactivated and never deleted.
| Column | Type | Required | Description |
|---|---|---|---|
id | uuid | yes | Primary key (uuidv7(), time-ordered). |
created_at | timestamp(3) with time zone | yes | Row creation time. |
updated_at | timestamp(3) with time zone | yes | Last write time; the ORM sets it to now() on every update. |
label | text | yes | Ladder label S1 to S7 or SX, the unique key into the in-code ladder (src/features/tiers/ladder.ts) that holds everything the tier entitles. |
rank | integer | yes | Ladder position copied from the in-code ladder on insert, never from a request; unique, orders tiers and decides upgrade versus downgrade and greedy assignment. |
provider | text | no | Payment provider the row bills through: stripe (CHECK tier_provider_check), or NULL when provider_product_id is NULL, as on the SX row. |
provider_product_id | text | no | Provider Product id (Stripe prod_...) chosen from the provider catalogue and verified before write; null on the custom SX row, which is never purchasable. |
price_cents | integer | no | Display cache of the product default price in minor units, written on verify and refreshed by the provider price webhooks; nothing does arithmetic on it. |
currency | text | no | Display cache beside price_cents: lower-case ISO currency code of the provider default price, written on verify and by the price webhooks. |
is_custom | boolean | yes | Copied from the in-code ladder on insert (true only for SX); identity like label and rank, never changed by a patch. |
is_active | boolean | yes | Set false by a superadmin to hide the tier from new purchases; rows are deactivated, never deleted, so seats that count against it keep resolving. |
Last updated on