Phase 7+8: Pretix + Sessionize interfaces

- Migration 20260825000000_interfaces.sql: external_id on contacts/
  registrations/sessions (+ partial unique indexes), slots_id_seq, sync_runs
  audit table, and service-role-only sync_pretix_attendees /
  sync_sessionize_sessions RPCs (idempotent upserts).
- sync-trigger Edge Function: admin-JWT or CRON_SECRET auth, pulls from
  Pretix/Sessionize base URLs, normalizes, calls the service-role RPCs.
- interfaces/mock-api: dependency-free Node server (:54330) + fixtures so the
  full pipeline is testable without real tokens.
- APPE Admin 'Interfaces' view: per-source + 'Sync all' triggers, result
  counts, recent sync runs, and QR CSV export; /functions proxy added.
- Docs: new docs/backend/interfaces.md; updated README, roadmap, next-steps,
  schema, rls, rpcs, architecture, admin-app, and docs index.

Co-authored-by: Stephan Charles <[email protected]>
Co-authored-by: Amelia Hernandez <[email protected]>
Co-authored-by: Markus Franz <[email protected]>
Co-authored-by: Sabrina Hota <[email protected]>
Co-authored-by: Nilüfer Doğan <[email protected]>
This commit is contained in:
committed 2026-08-23 03:34:30 +02:00
1 parent 7605c9bbf4
commit 74c41c8c1d
26 files changed
+1529 -80

No files matched your search

+29 -4
View File
@@ -4,10 +4,11 @@ All tables live in the `public` schema. Source of truth:
[`supabase/migrations/20260824000000_redesign.sql`](../../supabase/migrations/20260824000000_redesign.sql)
(the Redesign migration, which **replaces** the old `profiles`-based schema).
There are **13 tables**: people (`contacts`), the event (`events`), participation
There are **14 tables**: people (`contacts`), the event (`events`), participation
(`registrations`, `sponsors`), the schedule (`slots`, `sessions`,
`session_speakers`), and the event's activity (`preferences`, `connections`,
`checkins`, `feedback`, `leaderboard`, `points_log`).
`session_speakers`), the event's activity (`preferences`, `connections`,
`checkins`, `feedback`, `leaderboard`, `points_log`), and the interface audit
(`sync_runs`).
The old `profiles` table is **dropped**. People are now `contacts` (keyed by
email), and every activity table is scoped to an **event** + a **contact email**
@@ -54,9 +55,11 @@ One row per person. **`email` is the primary key** (a natural key that matches
| `show_linkedin` | `boolean` | default `false` — visibility toggle |
| `is_admin` | `boolean` | default `false` — **staff = admin (merged)**; grants check-in + APPE Admin access |
| `qr_token` | `text` **unique** | The lanyard token; **doubles as the Auth password** |
| `external_id` | `text` | nullable — the Pretix order code (set by the sync) |
| `created_at` | `timestamptz` | |
Index: `contacts_qr_token_idx (qr_token)` — fast lanyard lookups.
Partial unique index: `contacts_external_id_uniq (external_id) WHERE external_id IS NOT NULL`.
## `events` — a conference
@@ -93,10 +96,11 @@ Points are scoped **per event** here (one row per contact per event).
| `type` | `text` | `attendee` \| `speaker` \| `staff` \| `sponsor` (default `attendee`) |
| `checked_in` | `boolean` | default `false` |
| `points` | `integer` | `>= 0`, default 0 |
| `external_id` | `text` | nullable — the Pretix order code (set by the sync) |
| `created_at` | `timestamptz` | |
**Constraint:** `unique (event_id, contact_email)` — one registration per contact
per event.
per event. Partial unique index: `registrations_external_id_uniq (external_id) WHERE external_id IS NOT NULL`.
## `sponsors` — a sponsor for an event
@@ -140,6 +144,7 @@ Unpaid sponsors are hidden from non-admins (RLS).
| `average_feedback` | `numeric` | maintained by `submit_feedback` |
| `ai_generated_feedback` | `text` | AI-feedback state (stub) |
| `material_path` | `text` | nullable — storage object path for session material |
| `external_id` | `text` | nullable — the Sessionize session id (set by the sync) |
| `created_at` | `timestamptz` | |
> **Speakers are no longer a `text` column** — they live in the `session_speakers`
@@ -147,6 +152,7 @@ Unpaid sponsors are hidden from non-admins (RLS).
> comma-separated `speakers` string for display.
Indexes: `sessions_event_id_idx (event_id)`, `sessions_slot_id_idx (slot_id)`.
Partial unique index: `sessions_external_id_uniq (external_id) WHERE external_id IS NOT NULL`.
## `session_speakers` — M:N between sessions and contacts
@@ -253,6 +259,25 @@ Powers the per-category points breakdown on the Profile screen (per event).
Index: `points_log_event_id_idx (event_id)`.
## `sync_runs` — interface sync audit
One row per Pretix/Sessionize sync run, written by the service-role-only sync
RPCs (see [interfaces.md](./interfaces.md)).
| Column | Type | Notes |
|---|---|---|
| `id` | `uuid` PK | `gen_random_uuid()` |
| `source` | `text` | `pretix` \| `sessionize` |
| `started_at` | `timestamptz` | |
| `finished_at` | `timestamptz` | nullable |
| `created` | `integer` | rows created |
| `updated` | `integer` | rows updated |
| `skipped` | `integer` | rows skipped |
| `error` | `text` | nullable — top-level error, if any |
| `triggered_by` | `text` | default `service_role` |
Index: `sync_runs_source_idx (source)`. RLS: admin-only `select`.
## Other indexes
- `slots_event_id_idx (event_id)`, `registrations_event_id_idx (event_id)`,