OXYGENHUB
◆ v0.9.19 oxygenhub / crates / hub / migrations / 0101_push_devices.sql
650 B · SQL · last changed Phone alerts: a phone registers its Cloud Messaging token and key (PUT /api/v1/user/push), and each notification its account is told goes to it sealed to that key, sent keyless as the VM's service account; pins OxygenFlow main (refs oxygenhub-android#16) 8 days ago source blame history raw
1
-- Phones that take alerts (oxygenhub-android#16): one per device sign-in,
2
-- gone with it when the token is revoked. The Cloud Messaging registration
3
-- token addresses the phone; alerts are sealed to its X25519 public key
4
-- (hex), so the push service sees only ciphertext.
5
CREATE TABLE push_devices (
6
    token_id   INTEGER PRIMARY KEY REFERENCES tokens(id) ON DELETE CASCADE,
7
    account_id INTEGER NOT NULL REFERENCES accounts(id) ON DELETE CASCADE,
8
    fcm_token  TEXT NOT NULL,
9
    public_key TEXT NOT NULL,
10
    created_ms INTEGER NOT NULL,
11
    updated_ms INTEGER NOT NULL
12
);
13
CREATE INDEX push_devices_by_account ON push_devices (account_id);