Tearleads

organization_billing_lifecycle_events API Postgres table

Immutable snapshots of billing transitions owned by Tearleads itself.

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

Description

Provider lifecycle events remain in their provider audit ledgers. This table records product lifecycle that has no payment-provider event, currently the inception and expiration of an organization's free trial. The seat fields capture the licensed-capacity effect at that instant; the period fields keep the original trial interval available after current billing state changes.

Columns

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

    Row id.

  • organization_iduuid
    • not null

    Organization whose free trial changed.

  • event_typetext
    • not null

    free_trial_initialized or free_trial_expired.

  • source_idtext
    • not null

    The trial's identity, trial:<organizationId>:<end> with an ISO-8601 end, shared by its two events and the seat events they caused. Unique per organization and event type, so a retried transition records once.

  • licensed_seat_countinteger
    • not null

    Licensed seats after the transition: the trial's capacity when it starts, 0 when it expires.

  • quantity_deltainteger
    • not null

    Change in licensed seats the transition made.

  • active_seat_countinteger
    • not null

    Members reachable from the Members group when the trial started, as its seat initialization counted them; 0 when it expires.

  • period_starts_attimestamp
    • not null

    When the trial started.

  • period_ends_attimestamp
    • not null

    When the trial was scheduled to end.

  • occurred_attimestamp
    • not null

    When the transition took effect: the trial's start, or for an expiry its scheduled end, however late the expiry sweep ran.

  • created_attimestamp
    • not null
    • default now()

    When the row was written: the trial's start, or the time the expiry sweep ran.

Indexes

  • organization_billing_lifecycle_events_source_idx(organization_id, event_type, source_id)
    • unique
  • organization_billing_lifecycle_events_org_occurred_idx(organization_id, occurred_at)