TurboPanel Docs
Database

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.

ColumnTypeRequiredDescription
iduuidyesPrimary key (uuidv7(), time-ordered).
created_attimestamp(3) with time zoneyesRow creation time.
updated_attimestamp(3) with time zoneyesLast write time; the ORM sets it to now() on every update.
organization_iduuidyesOrganization holding the grant; unique (uniq_allowance_organization), so an organization has zero or one row.
tier_iduuidyesAlways the SX custom-rung tier row (ensureCustomTierRow), stored rather than looked up by label so entitlement reads on the ingest path add no query.
quantityintegeryesFree 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.

ColumnTypeRequiredDescription
iduuidyesPrimary key (uuidv7(), time-ordered).
created_attimestamp(3) with time zoneyesRow creation time.
updated_attimestamp(3) with time zoneyesLast write time; the ORM sets it to now() on every update.
organization_iduuidyesParent organization row (on delete cascade).
server_iduuidnoServer 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_iduuidnoTier 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.
nametextnoOptional operator display name; this server is reserved for the colocated control-plane license minted at install and refused by POST /licenses.
tokentextnoArgon2id 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_attimestamp(3) with time zonenoSoft-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_attimestamp(3) with time zonenoSet 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.

ColumnTypeRequiredDescription
iduuidyesPrimary key (uuidv7(), time-ordered).
created_attimestamp(3) with time zoneyesRow creation time.
updated_attimestamp(3) with time zoneyesLast write time; the ORM sets it to now() on every update.
organization_iduuidnoOrganization subject; exactly one of organization_id and user_id is non-null (payer_subject_check), and it is unique per provider when set.
user_iduuidnoUser subject for a personal subscription; exactly one of organization_id and user_id is non-null (payer_subject_check), unique per provider when set.
providertextyesPayment provider that owns this customer; only stripe is allowed today (CHECK payer_provider_check), apple is reserved in comments but not accepted.
provider_customer_idtextyesProvider-side customer id (Stripe cus_...); unique together with provider and the conflict target of the webhook upsert.
tax_idtextnoValue 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).

ColumnTypeRequiredDescription
iduuidyesPrimary key (uuidv7(), time-ordered).
created_attimestamp(3) with time zoneyesRow creation time.
updated_attimestamp(3) with time zoneyesLast write time; the ORM sets it to now() on every update.
subscription_iduuidyesParent subscription row (on delete cascade).
tier_iduuidyesTier 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_idtextyesProvider-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_idtextyesProvider price the item bills at (Stripe price_...), projected from the item and restated by every mutation; the tier knows its product, not its price.
quantityintegeryesNumber 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.

ColumnTypeRequiredDescription
iduuidyesPrimary key (uuidv7(), time-ordered).
created_attimestamp(3) with time zoneyesRow creation time.
updated_attimestamp(3) with time zoneyesLast write time; the ORM sets it to now() on every update.
payer_iduuidyesParent payer row (on delete cascade).
statustextyesChecked status: incomplete, incomplete_expired, trialing, active, past_due, canceled, unpaid, paused, or unknown for an unrecognised value.
provider_subscription_idtextyesProvider-side subscription id (Stripe sub_...); unique and the conflict target of the webhook upsert.
provider_statustextyesProvider 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_endtimestamp(3) with time zonenoEnd 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_idtextnoProvider subscription schedule id (Stripe sub_sched_...) while a downgrade is parked on a schedule; null otherwise, written by the webhook projection.
grace_expires_attimestamp(3) with time zonenoAlways 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_sincetimestamp(3) with time zonenoFirst 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.

ColumnTypeRequiredDescription
iduuidyesPrimary key (uuidv7(), time-ordered).
created_attimestamp(3) with time zoneyesRow creation time.
organization_iduuidyesParent organization row (on delete cascade).
license_iduuidnoRegistration key a join ticket binds when its server enrolls; null for a re-enroll ticket, CASCADE on delete.
server_iduuidnoThe 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_iduuidnoServer the spent ticket produced or re-keyed, SET NULL on delete.
created_by_user_iduuidnoUser who issued the ticket, SET NULL on delete.
server_nametextnoDisplay name chosen in Add Server for a join ticket; informational.
tokentextyesArgon2id PHC hash of the ticket secret; the plaintext is returned once at mint and cannot be recovered from this row.
expires_attimestamp(3) with time zoneyesMint time plus one hour; past it the ticket is refused.
used_attimestamp(3) with time zonenoSet 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.

ColumnTypeRequiredDescription
iduuidyesPrimary key (uuidv7(), time-ordered).
created_attimestamp(3) with time zoneyesRow creation time.
updated_attimestamp(3) with time zoneyesLast write time; the ORM sets it to now() on every update.
labeltextyesLadder 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.
rankintegeryesLadder position copied from the in-code ladder on insert, never from a request; unique, orders tiers and decides upgrade versus downgrade and greedy assignment.
providertextnoPayment 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_idtextnoProvider Product id (Stripe prod_...) chosen from the provider catalogue and verified before write; null on the custom SX row, which is never purchasable.
price_centsintegernoDisplay cache of the product default price in minor units, written on verify and refreshed by the provider price webhooks; nothing does arithmetic on it.
currencytextnoDisplay cache beside price_cents: lower-case ISO currency code of the provider default price, written on verify and by the price webhooks.
is_custombooleanyesCopied from the in-code ladder on insert (true only for SX); identity like label and rank, never changed by a patch.
is_activebooleanyesSet false by a superadmin to hide the tier from new purchases; rows are deactivated, never deleted, so seats that count against it keep resolving.
Edit on GitHub

Last updated on

On this page