-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path20260601000000_add_notify_same_day_to_events.sql
More file actions
27 lines (23 loc) · 1.28 KB
/
Copy path20260601000000_add_notify_same_day_to_events.sql
File metadata and controls
27 lines (23 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
begin;
-- ============================================================================
-- Same-day-alert opt-in for event submissions
-- ----------------------------------------------------------------------------
-- When an organiser submits an event they can ask to be told if we later
-- approve ANOTHER event that shares their day + city + category. This flag
-- records that opt-in on the event row itself, so when a new event B is
-- approved we can find the already-listed events A whose organisers opted in
-- and email them (see lib/events/notifications.ts → notifyOrganisersOfSameDayClash).
--
-- Default false: existing rows and non-opted-in submissions never trigger an
-- alert. The app code reads/writes this best-effort — submissions still
-- succeed if this migration hasn't run yet; the alerts simply stay dormant
-- until it does.
-- ============================================================================
alter table public.events
add column if not exists notify_same_day boolean not null default false;
-- Partial index: the approval-time lookup only ever filters on opted-in rows,
-- which are the minority, so a partial index keeps it tiny.
create index if not exists events_notify_same_day_idx
on public.events (notify_same_day)
where notify_same_day = true;
commit;