| 1 | -- Push for the native apps (slice 2): each paired device credential's |
| 2 | -- APNs registration, running Live Activities' update tokens, the outbox |
| 3 | -- the engine writes in the transaction of a change, what each person's |
| 4 | -- devices were last told about a task they started, and each once-only |
| 5 | -- push decided for a person. Tokens and payloads are sealed. Cards open |
| 6 | -- before push existed count as alerted: they opened before any device |
| 7 | -- could hear of them. |
| 8 | CREATE TABLE push_registrations (credential text PRIMARY KEY, person text, token text, environment text, platform text, start_token text, created_at datetime, updated_at datetime); |
| 9 | CREATE INDEX push_registration_person ON push_registrations(person); |
| 10 | CREATE TABLE push_activities (credential text, task_id text, person text, token text, created_at datetime, PRIMARY KEY (credential, task_id)); |
| 11 | CREATE INDEX push_activity_person ON push_activities(person); |
| 12 | CREATE TABLE push_outbox (id text PRIMARY KEY, person text, credential text, kind text, target text, task_id text, push_type text, priority integer, collapse_id text, dedupe text, payload text, state text, next_at datetime, attempts integer, lease_until datetime, status integer, reason text, apns_id text, sent_at datetime, created_at datetime, updated_at datetime); |
| 13 | CREATE INDEX push_outbox_due ON push_outbox(state, next_at); |
| 14 | CREATE INDEX push_outbox_dedupe ON push_outbox(dedupe); |
| 15 | CREATE INDEX push_outbox_credential ON push_outbox(credential); |
| 16 | CREATE INDEX push_outbox_person ON push_outbox(person); |
| 17 | CREATE TABLE push_tasks (person text, task_id text, title text, tone text, stage text, needs_you text, specialist text, step_id text, activity text, started_at datetime, ended numeric, line_at datetime, updated_at datetime, PRIMARY KEY (person, task_id)); |
| 18 | CREATE TABLE push_once (person text, key text, created_at datetime, PRIMARY KEY (person, key)); |
| 19 | INSERT INTO push_once (person, key, created_at) SELECT person, 'card:' || id, CURRENT_TIMESTAMP FROM chat_cards WHERE state IN ('open', 'ask'); |
| 20 | |