The one ACTIVE subscription for this (userId, sku, sellerId), or null; subscribe uses it to refuse a second active subscription, which would double-bill.
Optionaloptions: CallOptionsSets the row CANCELED whatever state it held; an unknown id changes nothing. Terminal: a canceled subscription never claims due again.
Optionaloptions: CallOptionsFinds up to limit subscriptions whose next charge is due, for the renewal sweep.
Optionaloptions: CallOptionsOptionaloptions: CallOptionsRecords a successful renewal as a compare-and-set against the period the sweeper claimed
(next_due_at = expectedDueAt); returns false and changes nothing when another sweeper
already billed the period, so the loser never double-charges.
Optionaloptions: CallOptionsMarks a subscription LAPSED because a renewal couldn't be paid — distinct from a user-requested cancel; either way the sweep stops re-billing it.
Optionaloptions: CallOptionsUpserts by sub.id. Called inside subscribe's first-charge transaction, so an open
subscription without its anchor posting never survives.
Optionaloptions: CallOptions
Tracks recurring subscriptions and when each is next due to bill.