Skip to main content

max / goingson

2.4 KB · 64 lines History Blame Raw
1 -- Event snooze: hide events from main calendar/list views until a date passes.
2 -- Mirrors the existing task and email snooze pattern. Synced via existing
3 -- sync_changelog triggers, which must be rebuilt to include the new column.
4
5 ALTER TABLE events ADD COLUMN snoozed_until TEXT;
6
7 -- ── Rebuild event sync triggers to include snoozed_until (18 cols total) ──
8
9 DROP TRIGGER IF EXISTS sync_trg_events_insert;
10 CREATE TRIGGER IF NOT EXISTS sync_trg_events_insert
11 AFTER INSERT ON events
12 WHEN (SELECT value FROM sync_state WHERE key = 'applying_remote') != '1'
13 BEGIN
14 INSERT INTO sync_changelog (table_name, op, row_id, data)
15 VALUES ('events', 'INSERT', NEW.id, json_object(
16 'id', NEW.id,
17 'project_id', NEW.project_id,
18 'title', NEW.title,
19 'description', NEW.description,
20 'start_time', NEW.start_time,
21 'end_time', NEW.end_time,
22 'location', NEW.location,
23 'user_id', NEW.user_id,
24 'linked_task_id', NEW.linked_task_id,
25 'recurrence', NEW.recurrence,
26 'recurrence_parent_id', NEW.recurrence_parent_id,
27 'recurrence_rule', NEW.recurrence_rule,
28 'contact_id', NEW.contact_id,
29 'block_type', NEW.block_type,
30 'external_source', NEW.external_source,
31 'external_id', NEW.external_id,
32 'is_read_only', NEW.is_read_only,
33 'snoozed_until', NEW.snoozed_until
34 ));
35 END;
36
37 DROP TRIGGER IF EXISTS sync_trg_events_update;
38 CREATE TRIGGER IF NOT EXISTS sync_trg_events_update
39 AFTER UPDATE ON events
40 WHEN (SELECT value FROM sync_state WHERE key = 'applying_remote') != '1'
41 BEGIN
42 INSERT INTO sync_changelog (table_name, op, row_id, data)
43 VALUES ('events', 'UPDATE', NEW.id, json_object(
44 'id', NEW.id,
45 'project_id', NEW.project_id,
46 'title', NEW.title,
47 'description', NEW.description,
48 'start_time', NEW.start_time,
49 'end_time', NEW.end_time,
50 'location', NEW.location,
51 'user_id', NEW.user_id,
52 'linked_task_id', NEW.linked_task_id,
53 'recurrence', NEW.recurrence,
54 'recurrence_parent_id', NEW.recurrence_parent_id,
55 'recurrence_rule', NEW.recurrence_rule,
56 'contact_id', NEW.contact_id,
57 'block_type', NEW.block_type,
58 'external_source', NEW.external_source,
59 'external_id', NEW.external_id,
60 'is_read_only', NEW.is_read_only,
61 'snoozed_until', NEW.snoozed_until
62 ));
63 END;
64