-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathschema.sql
More file actions
94 lines (78 loc) · 3.28 KB
/
Copy pathschema.sql
File metadata and controls
94 lines (78 loc) · 3.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
-- Gatekeeper D1 analytics schema
-- Single source of truth. Applied via: wrangler d1 execute gatekeeper-analytics --file=schema.sql
-- To nuke and recreate: wrangler d1 execute gatekeeper-analytics --file=schema.sql --remote
-- ─── Purge events ───────────────────────────────────────────────────────────
DROP TABLE IF EXISTS purge_events;
CREATE TABLE purge_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
key_id TEXT NOT NULL,
zone_id TEXT NOT NULL,
purge_type TEXT NOT NULL,
purge_target TEXT,
tokens INTEGER NOT NULL DEFAULT 1,
status INTEGER NOT NULL,
collapsed TEXT,
upstream_status INTEGER,
duration_ms INTEGER NOT NULL,
response_detail TEXT,
created_by TEXT,
flight_id TEXT,
created_at INTEGER NOT NULL
);
CREATE INDEX idx_purge_events_zone_created ON purge_events (zone_id, created_at DESC);
CREATE INDEX idx_purge_events_key_created ON purge_events (key_id, created_at DESC);
-- ─── S3 events ──────────────────────────────────────────────────────────────
DROP TABLE IF EXISTS s3_events;
CREATE TABLE s3_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
credential_id TEXT NOT NULL,
operation TEXT NOT NULL,
bucket TEXT,
key TEXT,
status INTEGER NOT NULL,
duration_ms INTEGER NOT NULL,
response_detail TEXT,
created_by TEXT,
created_at INTEGER NOT NULL
);
CREATE INDEX idx_s3_events_cred_created ON s3_events (credential_id, created_at DESC);
CREATE INDEX idx_s3_events_bucket_created ON s3_events (bucket, created_at DESC);
-- ─── DNS events ─────────────────────────────────────────────────────────────
DROP TABLE IF EXISTS dns_events;
CREATE TABLE dns_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
key_id TEXT NOT NULL,
zone_id TEXT NOT NULL,
action TEXT NOT NULL,
record_name TEXT,
record_type TEXT,
status INTEGER NOT NULL,
upstream_status INTEGER,
duration_ms INTEGER NOT NULL,
response_detail TEXT,
created_by TEXT,
created_at INTEGER NOT NULL
);
CREATE INDEX idx_dns_events_key_created ON dns_events (key_id, created_at DESC);
CREATE INDEX idx_dns_events_zone_created ON dns_events (zone_id, created_at DESC);
-- ─── CF proxy events ────────────────────────────────────────────────────────
DROP TABLE IF EXISTS cf_proxy_events;
CREATE TABLE cf_proxy_events (
id INTEGER PRIMARY KEY AUTOINCREMENT,
key_id TEXT NOT NULL,
account_id TEXT NOT NULL,
service TEXT NOT NULL,
action TEXT NOT NULL,
resource_id TEXT,
status INTEGER NOT NULL,
upstream_status INTEGER,
duration_ms INTEGER NOT NULL,
upstream_latency_ms INTEGER,
response_size INTEGER,
response_detail TEXT,
created_by TEXT,
created_at INTEGER NOT NULL
);
CREATE INDEX idx_cf_proxy_key_created ON cf_proxy_events (key_id, created_at DESC);
CREATE INDEX idx_cf_proxy_account_created ON cf_proxy_events (account_id, created_at DESC);
CREATE INDEX idx_cf_proxy_service_created ON cf_proxy_events (service, created_at DESC);