Tearleads

organization_billing_seat_assignments API Postgres table

Current and historical billable-seat assignments for an organization.

Declared in packages/api-shared/src/schema/organizationBillingSeats.ts

Description

A row represents one user occupying one licensed seat during one billing period. Releasing a user frees that seat for reuse during the same period; adding more simultaneously-active users than the licensed seat count creates an accounting event that can be pushed to the billing provider.

Columns

  • iduuid
    • primary key
    • not null
    • default gen_random_uuid()

    Assignment id.

  • organization_iduuid
    • not null

    Organization whose seat this is.

  • user_iduuid
    • not null

    Member occupying the seat. A user holds at most one open assignment per organization.

  • billing_period_starts_attimestamp
    • nullable

    The organization's paid period when the seat was assigned; null when it had none, as in a trial.

  • billing_period_ends_attimestamp
    • nullable

    The organization's paid period when the seat was assigned; null when it had none, as in a trial.

  • assigned_attimestamp
    • not null

    When the seat was assigned.

  • released_attimestamp
    • nullable

    When the seat was released; null while the user holds it.

  • assignment_source_typetext
    • not null

    What assigned the seat: principal_state with the signed policy state hash that changed the roster, provider_event with a RevenueCat event id, or billing_transition with an internal id such as a trial's trial:<organizationId>:<end>.

  • assignment_source_idtext
    • not null

    What assigned the seat: principal_state with the signed policy state hash that changed the roster, provider_event with a RevenueCat event id, or billing_transition with an internal id such as a trial's trial:<organizationId>:<end>.

  • release_source_typetext
    • nullable

    What released the seat, in the same form; null while it is open.

  • release_source_idtext
    • nullable

    What released the seat, in the same form; null while it is open.

  • created_attimestamp
    • not null
    • default now()

    Server-side row timestamps.

  • updated_attimestamp
    • not null
    • default now()

    Server-side row timestamps.

Indexes

  • organization_billing_seat_assignments_org_open_idx(organization_id, released_at)
    • organization_billing_seat_assignments_org_user_idx(organization_id, user_id, released_at)
      • organization_billing_seat_assignments_org_user_open_uidx(organization_id, user_id)
        • unique
        • partial: where "released_at" is null