feat: add event-scoped schedule deletion and import date guard
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:
1 parent
15789ab04d
commit
22de4a8645
12 files changed
+2034
-14
No files matched your search
@@ -210,6 +210,25 @@ existing uploaded `materials` object under `sessions/<this session UUID>/<filena
|
||||
There is no active-event, date, check-in or points condition. Shared by Agenda and
|
||||
the [speaker portal](../frontend/screens.md#speaker-portal).
|
||||
|
||||
### `delete_event_schedule(p_event_id)` → `jsonb`
|
||||
**Admin-only.** Deletes the slots and sessions for exactly one event in a single
|
||||
transaction. It locks the event plus that event's schedule rows, validates that
|
||||
sessions and dependent `preferences` / `checkins` / `feedback` rows do not cross
|
||||
event boundaries, then deletes `sessions` and `slots` for `p_event_id`.
|
||||
|
||||
FK cascades remove `session_speakers`, `preferences`, `checkins` and
|
||||
`feedback`. The event row, contacts, registrations, sponsors, connections,
|
||||
points, leaderboard rows and other events are preserved. Session
|
||||
`material_path` values disappear with the deleted session rows, but Storage
|
||||
objects in the `materials` bucket are not physically purged.
|
||||
|
||||
The function is `security definer` with an empty `search_path`, requires both
|
||||
`auth.uid()` and `public.is_admin()`, revokes execution from `PUBLIC` / `anon` /
|
||||
`authenticated`, then grants execution back only to `authenticated`. It returns
|
||||
counts for deleted slots, sessions and dependent rows plus the number of
|
||||
material paths left unpurged. It does not coordinate with Sessionize/Pretix
|
||||
sync; a concurrent or later import can repopulate the event schedule.
|
||||
|
||||
## Speaker Portal RPCs
|
||||
|
||||
Source: [20261006175631_speaker_portal.sql](../../supabase/migrations/20261006175631_speaker_portal.sql),
|
||||
|
||||
@@ -50,6 +50,20 @@ contacts + registrations.
|
||||
Linking a speaker to a session fires the `session_speakers_speaker_promote`
|
||||
trigger, which promotes an existing registration to `speaker`.
|
||||
|
||||
Both import paths are guarded by the event's configured `start_date` /
|
||||
`end_date`: any Sessionize session dated outside that inclusive range aborts the
|
||||
RPC before speakers, sessions, slots, links, registrations, audit rows, or event
|
||||
sync timestamps are changed. The exception includes the bad date, the configured
|
||||
range, and the actionable check to verify the Sessionize endpoint, Excel export,
|
||||
or event dates. Existing historical rows outside the range are retained by later
|
||||
successful imports; deleting or reconciling them is a separate, explicitly
|
||||
approved data-repair task.
|
||||
|
||||
The date guard lives in
|
||||
[`20261009225632_guard_sessionize_dates.sql`](../../supabase/migrations/20261009225632_guard_sessionize_dates.sql).
|
||||
It is not automatically deployed by being present in the repository; apply it
|
||||
through the normal reviewed migration path for each environment.
|
||||
|
||||
## How it reaches things
|
||||
|
||||
```mermaid
|
||||
|
||||
@@ -88,6 +88,49 @@ authorization separately. See [screen contract](../frontend/screens.md#speaker-p
|
||||
[API client](../frontend/api-client.md#speaker-portal), [RLS](./rls.md#speaker-portal-authorization)
|
||||
and [RPCs](./rpcs.md#speaker-portal-rpcs).
|
||||
|
||||
## Sessionize Date Guard
|
||||
|
||||
[sessionize_date_guard_tests.sql](../../supabase/tests/sessionize_date_guard_tests.sql)
|
||||
is an independent fail-fast rollback-only suite for the Sessionize API and Excel
|
||||
RPC date guard. It creates generated event/contact/auth fixtures, precreates
|
||||
explicit negative slot IDs so successful imports do not allocate sequence values,
|
||||
and ends with `ROLLBACK`.
|
||||
|
||||
To verify the migration and suite together on the local database without
|
||||
persisting either change:
|
||||
|
||||
```bash
|
||||
{ printf 'BEGIN;\n'; cat supabase/migrations/20261009225632_guard_sessionize_dates.sql supabase/tests/sessionize_date_guard_tests.sql; printf '\nROLLBACK;\n'; } | docker exec -i supabase_db_Convivo psql -U postgres -d postgres -v ON_ERROR_STOP=1
|
||||
```
|
||||
|
||||
The nested `BEGIN` warning from the suite is harmless in this rollback-only
|
||||
check. This command is local validation only; it does not write CLI migration
|
||||
history and is not a production deployment. Historical rows outside the newly
|
||||
configured event range are retained by successful imports and need a separately
|
||||
approved reconciliation if they should be removed or changed.
|
||||
|
||||
## Delete Event Schedule
|
||||
|
||||
[delete_event_schedule_tests.sql](../../supabase/tests/delete_event_schedule_tests.sql)
|
||||
is an independent fail-fast rollback-only suite for the admin schedule-clear RPC.
|
||||
It creates generated contacts/events/auth fixtures, uses explicit negative slot
|
||||
IDs so fixture setup does not advance `slots_id_seq`, and ends with `ROLLBACK`.
|
||||
|
||||
To verify the migration and suite together on the local database without
|
||||
persisting either change:
|
||||
|
||||
```bash
|
||||
{ printf 'BEGIN;\n'; cat supabase/migrations/20261009231817_delete_event_schedule.sql supabase/tests/delete_event_schedule_tests.sql; printf '\nROLLBACK;\n'; } | docker exec -i supabase_db_Convivo psql -U postgres -d postgres -v ON_ERROR_STOP=1
|
||||
```
|
||||
|
||||
The suite checks authenticated admin execution, non-admin rejection, anon
|
||||
execute denial, missing-event rejection, exact delete counts, unchanged event
|
||||
selection, registrations, contacts, auth users, sponsors, connections, points,
|
||||
event feedback, leaderboard and other-event schedule rows. It also proves
|
||||
cross-event slot/dependent mismatches fail atomically instead of cascading
|
||||
foreign-event rows. This is local validation only; it does not write migration
|
||||
history or deploy anything.
|
||||
|
||||
## Files
|
||||
|
||||
- [`supabase/tests/rpc_tests.sql`](../../supabase/tests/rpc_tests.sql) — the test
|
||||
|
||||
Reference in new issue
Block a user