Festivals & ticketing
referrals
Referrals — ticket referral tracking for the "buy through a friend's link" discount flow. A referral row is created when a dancer opens a checkout via a referral link (?ref=<username>). Status transitions: pending → completed (on successful Stripe payment) or expired (if never paid). The referrer is credited once the referee's payment succeeds.
Columns
| Column | Type | Null | Default | Keys |
|---|---|---|---|---|
| id | uuid | no | gen_random_uuid() | PK |
| festival_id | uuid | no | — | |
| referrer_id | uuid | no | — | |
| referee_id | uuid | no | — | |
| discount_cents | integer | no | 0 | |
| stripe_session_id | text | yes | — | |
| status | text pendingcompletedexpired | no | "pending" | |
| created_at | timestamp | yes | now() | |
| completed_at | timestamp | yes | — | |
| referrer_credit_cents | integer | no | 0 | |
| referrer_credit_applied_session_id | text | yes | — |
Value lists come from .$type<'a' | 'b'>() in the schema — enforced in TypeScript only, not by the database.
Keys, constraints & indexes
Used by
Code that reads or writes this table, found by static analysis of the tRPC routers and API handlers (including helpers they call).
REST & webhooks
- POST /api/stripe/webhook
- ANY /mcp
- ANY /mcp/public
Relations
Rendering diagram…
Diagram source
erDiagram
dancers {
uuid id PK
text email UK
text neon_auth_id UK
text username UK
}
festivals {
uuid id PK
text slug UK
}
referrals {
uuid id PK
uuid festival_id FK
uuid referrer_id FK
uuid referee_id FK
}
festivals ||--o{ referrals : "festival_id"
dancers ||--o{ referrals : "referrer_id"
dancers ||--o{ referrals : "referee_id" Defined at server/database/schema.ts:945 as referrals.