Diffinery

homeflare/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

60 lines · 2.2 KBRaw History
1-- Email notifications: per-person settings, watching, thread subscriptions,
2-- recognised sign-in devices and a log of every email sent.
3
4-- One row per person who changed a default. JSON, see src/mail/prefs.ts.
5CREATE TABLE notification_prefs (
6 account_id TEXT PRIMARY KEY REFERENCES accounts(id),
7 prefs TEXT NOT NULL,
8 updated_at TEXT NOT NULL
9);
10
11-- Watching a repository: 'all' (every issue, pull request and failed run),
12-- 'participating' (the default: only threads you take part in) or 'ignore'.
13CREATE TABLE repo_watches (
14 account_id TEXT NOT NULL REFERENCES accounts(id),
15 repo_id TEXT NOT NULL REFERENCES repos(id) ON DELETE CASCADE,
16 level TEXT NOT NULL CHECK (level IN ('all', 'participating', 'ignore')),
17 updated_at TEXT NOT NULL,
18 PRIMARY KEY (account_id, repo_id)
19);
20CREATE INDEX repo_watches_repo ON repo_watches(repo_id, level);
21
22-- Subscribe to (1) or mute (0) one issue or pull request.
23CREATE TABLE thread_subscriptions (
24 account_id TEXT NOT NULL REFERENCES accounts(id),
25 repo_id TEXT NOT NULL,
26 number INTEGER NOT NULL,
27 subscribed INTEGER NOT NULL,
28 updated_at TEXT NOT NULL,
29 PRIMARY KEY (account_id, repo_id, number)
30);
31CREATE INDEX thread_subscriptions_thread ON thread_subscriptions(repo_id, number);
32
33-- Browsers and passkeys someone has signed in with, so only new ones raise an alert.
34CREATE TABLE known_devices (
35 account_id TEXT NOT NULL REFERENCES accounts(id),
36 fingerprint TEXT NOT NULL,
37 label TEXT NOT NULL,
38 first_seen TEXT NOT NULL,
39 last_seen TEXT NOT NULL,
40 PRIMARY KEY (account_id, fingerprint)
41);
42
43-- Every email Diffinery tried to send (whole messages are kept only in local development).
44CREATE TABLE email_log (
45 id TEXT PRIMARY KEY,
46 account_id TEXT,
47 to_addr TEXT NOT NULL,
48 kind TEXT NOT NULL,
49 subject TEXT NOT NULL,
50 status TEXT NOT NULL CHECK (status IN ('sent', 'failed', 'skipped')),
51 detail TEXT,
52 message_id TEXT,
53 dev_copy TEXT, -- the whole message, kept only in local development
54 created_at TEXT NOT NULL
55);
56CREATE INDEX email_log_at ON email_log(created_at);
57CREATE INDEX email_log_account ON email_log(account_id, created_at);
58
59-- Reminders sent once per token, a week before it expires.
60ALTER TABLE tokens ADD COLUMN expiry_notified_at TEXT;