oficina / home Public

Clone
git clone https://amadan.net/oficina/home

Plain git — no account needed to clone.

Download

Download this file

1[
2 {
3 "Type": "index",
4 "Name": "memberships_person",
5 "Table": "memberships",
6 "SQL": "CREATE INDEX memberships_person ON memberships(person_ref, team_id)"
7 },
8 {
9 "Type": "index",
10 "Name": "oficina_handoff_inbox_expiry",
11 "Table": "oficina_handoff_inbox",
12 "SQL": "CREATE INDEX oficina_handoff_inbox_expiry ON oficina_handoff_inbox(expires_at)"
13 },
14 {
15 "Type": "index",
16 "Name": "oficina_handoff_pending_expiry",
17 "Table": "oficina_handoff_pending",
18 "SQL": "CREATE INDEX oficina_handoff_pending_expiry ON oficina_handoff_pending(expires_at)"
19 },
20 {
21 "Type": "index",
22 "Name": "oficina_handoff_replay_expiry",
23 "Table": "oficina_handoff_replay",
24 "SQL": "CREATE INDEX oficina_handoff_replay_expiry ON oficina_handoff_replay(expires_at)"
25 },
26 {
27 "Type": "index",
28 "Name": "sqlite_autoindex_directory_operator_consumer_records_1",
29 "Table": "directory_operator_consumer_records",
30 "SQL": ""
31 },
32 {
33 "Type": "index",
34 "Name": "sqlite_autoindex_directory_operator_consumer_records_2",
35 "Table": "directory_operator_consumer_records",
36 "SQL": ""
37 },
38 {
39 "Type": "index",
40 "Name": "sqlite_autoindex_directory_operator_owner_receipts_1",
41 "Table": "directory_operator_owner_receipts",
42 "SQL": ""
43 },
44 {
45 "Type": "index",
46 "Name": "sqlite_autoindex_directory_operator_owner_receipts_2",
47 "Table": "directory_operator_owner_receipts",
48 "SQL": ""
49 },
50 {
51 "Type": "index",
52 "Name": "sqlite_autoindex_directory_operator_owner_receipts_3",
53 "Table": "directory_operator_owner_receipts",
54 "SQL": ""
55 },
56 {
57 "Type": "index",
58 "Name": "sqlite_autoindex_directory_operator_results_1",
59 "Table": "directory_operator_results",
60 "SQL": ""
61 },
62 {
63 "Type": "index",
64 "Name": "sqlite_autoindex_directory_operator_results_2",
65 "Table": "directory_operator_results",
66 "SQL": ""
67 },
68 {
69 "Type": "index",
70 "Name": "sqlite_autoindex_memberships_1",
71 "Table": "memberships",
72 "SQL": ""
73 },
74 {
75 "Type": "index",
76 "Name": "sqlite_autoindex_oficina_handoff_inbox_1",
77 "Table": "oficina_handoff_inbox",
78 "SQL": ""
79 },
80 {
81 "Type": "index",
82 "Name": "sqlite_autoindex_oficina_handoff_inbox_2",
83 "Table": "oficina_handoff_inbox",
84 "SQL": ""
85 },
86 {
87 "Type": "index",
88 "Name": "sqlite_autoindex_oficina_handoff_pending_1",
89 "Table": "oficina_handoff_pending",
90 "SQL": ""
91 },
92 {
93 "Type": "index",
94 "Name": "sqlite_autoindex_oficina_handoff_pending_2",
95 "Table": "oficina_handoff_pending",
96 "SQL": ""
97 },
98 {
99 "Type": "index",
100 "Name": "sqlite_autoindex_oficina_handoff_replay_1",
101 "Table": "oficina_handoff_replay",
102 "SQL": ""
103 },
104 {
105 "Type": "index",
106 "Name": "sqlite_autoindex_rastrillo_migrations_1",
107 "Table": "rastrillo_migrations",
108 "SQL": ""
109 },
110 {
111 "Type": "index",
112 "Name": "sqlite_autoindex_roster_consumers_1",
113 "Table": "roster_consumers",
114 "SQL": ""
115 },
116 {
117 "Type": "index",
118 "Name": "sqlite_autoindex_roster_operator_receipts_1",
119 "Table": "roster_operator_receipts",
120 "SQL": ""
121 },
122 {
123 "Type": "index",
124 "Name": "sqlite_autoindex_roster_tokens_1",
125 "Table": "roster_tokens",
126 "SQL": ""
127 },
128 {
129 "Type": "index",
130 "Name": "sqlite_autoindex_roster_tokens_2",
131 "Table": "roster_tokens",
132 "SQL": ""
133 },
134 {
135 "Type": "index",
136 "Name": "sqlite_autoindex_sessions_1",
137 "Table": "sessions",
138 "SQL": ""
139 },
140 {
141 "Type": "index",
142 "Name": "sqlite_autoindex_team_instances_1",
143 "Table": "team_instances",
144 "SQL": ""
145 },
146 {
147 "Type": "index",
148 "Name": "sqlite_autoindex_team_instances_2",
149 "Table": "team_instances",
150 "SQL": ""
151 },
152 {
153 "Type": "index",
154 "Name": "sqlite_autoindex_team_instances_3",
155 "Table": "team_instances",
156 "SQL": ""
157 },
158 {
159 "Type": "index",
160 "Name": "sqlite_autoindex_teams_1",
161 "Table": "teams",
162 "SQL": ""
163 },
164 {
165 "Type": "index",
166 "Name": "sqlite_autoindex_teams_2",
167 "Table": "teams",
168 "SQL": ""
169 },
170 {
171 "Type": "index",
172 "Name": "sqlite_autoindex_verification_active_1",
173 "Table": "verification_active",
174 "SQL": ""
175 },
176 {
177 "Type": "index",
178 "Name": "sqlite_autoindex_verification_active_2",
179 "Table": "verification_active",
180 "SQL": ""
181 },
182 {
183 "Type": "index",
184 "Name": "sqlite_autoindex_verification_attempts_1",
185 "Table": "verification_attempts",
186 "SQL": ""
187 },
188 {
189 "Type": "index",
190 "Name": "sqlite_autoindex_verification_outcomes_1",
191 "Table": "verification_outcomes",
192 "SQL": ""
193 },
194 {
195 "Type": "table",
196 "Name": "_litestream_lock",
197 "Table": "_litestream_lock",
198 "SQL": "CREATE TABLE _litestream_lock (id INTEGER)"
199 },
200 {
201 "Type": "table",
202 "Name": "_litestream_seq",
203 "Table": "_litestream_seq",
204 "SQL": "CREATE TABLE _litestream_seq (id INTEGER PRIMARY KEY, seq INTEGER)"
205 },
206 {
207 "Type": "table",
208 "Name": "directory_operator_consumer_records",
209 "Table": "directory_operator_consumer_records",
210 "SQL": "CREATE TABLE directory_operator_consumer_records (\n consumer_id TEXT PRIMARY KEY REFERENCES roster_consumers(consumer_id),\n operation_id TEXT NOT NULL UNIQUE REFERENCES roster_operator_receipts(operation_id),\n sequence INTEGER NOT NULL CHECK(typeof(sequence)='integer' AND sequence\u003e0),\n generation TEXT NOT NULL CHECK(length(generation)=43),\n record_digest BLOB NOT NULL CHECK(typeof(record_digest)='blob' AND length(record_digest)=32)\n)"
211 },
212 {
213 "Type": "table",
214 "Name": "directory_operator_owner_receipts",
215 "Table": "directory_operator_owner_receipts",
216 "SQL": "CREATE TABLE directory_operator_owner_receipts (\n issuer TEXT NOT NULL,\n owner_operation_id TEXT NOT NULL CHECK(length(owner_operation_id)=43),\n directory_operation_id TEXT NOT NULL UNIQUE REFERENCES directory_operator_results(operation_id) DEFERRABLE INITIALLY DEFERRED,\n team_id INTEGER NOT NULL UNIQUE REFERENCES teams(id),\n PRIMARY KEY(issuer,owner_operation_id)\n)"
217 },
218 {
219 "Type": "table",
220 "Name": "directory_operator_results",
221 "Table": "directory_operator_results",
222 "SQL": "CREATE TABLE directory_operator_results (\n operation_id TEXT PRIMARY KEY CHECK(length(operation_id)=43),\n action TEXT NOT NULL,\n sequence INTEGER NOT NULL UNIQUE CHECK(typeof(sequence)='integer' AND sequence\u003e0),\n authorization_head TEXT NOT NULL CHECK(length(authorization_head)=43),\n request_mac BLOB NOT NULL CHECK(typeof(request_mac)='blob' AND length(request_mac)=32),\n sealed_result BLOB NOT NULL CHECK(typeof(sealed_result)='blob' AND length(sealed_result) BETWEEN 29 AND 49180),\n completed_at INTEGER NOT NULL CHECK(typeof(completed_at)='integer' AND completed_at\u003e0)\n, operator_ref TEXT NOT NULL DEFAULT '')"
223 },
224 {
225 "Type": "table",
226 "Name": "directory_operator_state",
227 "Table": "directory_operator_state",
228 "SQL": "CREATE TABLE directory_operator_state (\n singleton INTEGER PRIMARY KEY CHECK(singleton=1),\n origin TEXT NOT NULL,\n installation TEXT NOT NULL,\n registry TEXT NOT NULL,\n device TEXT NOT NULL,\n sequence INTEGER NOT NULL CHECK(typeof(sequence)='integer' AND sequence\u003e0),\n head TEXT NOT NULL CHECK(length(head)=43),\n completed_at INTEGER NOT NULL CHECK(typeof(completed_at)='integer' AND completed_at\u003e0)\n, key_id TEXT NOT NULL DEFAULT '')"
229 },
230 {
231 "Type": "table",
232 "Name": "memberships",
233 "Table": "memberships",
234 "SQL": "CREATE TABLE memberships (\n team_id INTEGER NOT NULL REFERENCES teams(id) ON DELETE RESTRICT,\n person_ref TEXT NOT NULL CHECK(length(person_ref) = 29 AND substr(person_ref,1,3) = 'pr_' AND substr(person_ref,4) NOT GLOB '*[^a-z2-7]*'),\n role TEXT NOT NULL CHECK(role IN ('owner', 'member')),\n PRIMARY KEY(team_id, person_ref)\n)"
235 },
236 {
237 "Type": "table",
238 "Name": "oficina_handoff_clock",
239 "Table": "oficina_handoff_clock",
240 "SQL": "CREATE TABLE oficina_handoff_clock (\n id INTEGER PRIMARY KEY CHECK (id = 1),\n observed INTEGER NOT NULL\n)"
241 },
242 {
243 "Type": "table",
244 "Name": "oficina_handoff_inbox",
245 "Table": "oficina_handoff_inbox",
246 "SQL": "CREATE TABLE oficina_handoff_inbox (\n handle_hash TEXT PRIMARY KEY,\n jti_hash TEXT NOT NULL UNIQUE,\n sealed_token BLOB NOT NULL,\n created_at INTEGER NOT NULL,\n expires_at INTEGER NOT NULL\n)"
247 },
248 {
249 "Type": "table",
250 "Name": "oficina_handoff_pending",
251 "Table": "oficina_handoff_pending",
252 "SQL": "CREATE TABLE oficina_handoff_pending (\n secret_hash TEXT PRIMARY KEY,\n nonce_hash TEXT NOT NULL UNIQUE,\n sealed_path BLOB NOT NULL,\n created_at INTEGER NOT NULL,\n expires_at INTEGER NOT NULL\n)"
253 },
254 {
255 "Type": "table",
256 "Name": "oficina_handoff_replay",
257 "Table": "oficina_handoff_replay",
258 "SQL": "CREATE TABLE oficina_handoff_replay (\n jti_hash TEXT PRIMARY KEY,\n expires_at INTEGER NOT NULL\n)"
259 },
260 {
261 "Type": "table",
262 "Name": "rastrillo_migrations",
263 "Table": "rastrillo_migrations",
264 "SQL": "CREATE TABLE rastrillo_migrations (\n id TEXT PRIMARY KEY,\n applied_at TEXT NOT NULL,\n checksum TEXT NOT NULL\n)"
265 },
266 {
267 "Type": "table",
268 "Name": "roster_consumers",
269 "Table": "roster_consumers",
270 "SQL": "CREATE TABLE roster_consumers (\n consumer_id TEXT PRIMARY KEY REFERENCES team_instances(consumer_id) ON DELETE RESTRICT,\n team_id INTEGER NOT NULL REFERENCES teams(id) ON DELETE RESTRICT,\n app TEXT NOT NULL,\n origin TEXT NOT NULL,\n enabled INTEGER NOT NULL CHECK(enabled IN (0,1)),\n FOREIGN KEY(team_id,app) REFERENCES team_instances(team_id,app) ON DELETE RESTRICT\n)"
271 },
272 {
273 "Type": "table",
274 "Name": "roster_generation",
275 "Table": "roster_generation",
276 "SQL": "CREATE TABLE roster_generation (\n singleton INTEGER PRIMARY KEY CHECK(singleton = 1),\n generation TEXT NOT NULL CHECK(length(generation) = 43 AND generation NOT GLOB '*[^a-zA-Z0-9_-]*')\n)"
277 },
278 {
279 "Type": "table",
280 "Name": "roster_operator_receipts",
281 "Table": "roster_operator_receipts",
282 "SQL": "CREATE TABLE roster_operator_receipts (\n operation_id TEXT PRIMARY KEY CHECK(length(operation_id) BETWEEN 1 AND 128 AND operation_id NOT GLOB '*[^a-zA-Z0-9_-]*'),\n sequence INTEGER NOT NULL CHECK(typeof(sequence) = 'integer' AND sequence \u003e 0),\n operation TEXT NOT NULL CHECK(operation IN ('bootstrap','provision','rotate','disable','restore')),\n consumer_id TEXT CHECK(consumer_id IS NULL OR (length(consumer_id) BETWEEN 1 AND 128 AND consumer_id NOT GLOB '*[^a-zA-Z0-9_-]*')),\n generation TEXT NOT NULL CHECK(length(generation) = 43 AND generation NOT GLOB '*[^a-zA-Z0-9_-]*'),\n record_digest BLOB NOT NULL CHECK(typeof(record_digest) = 'blob' AND length(record_digest) = 32),\n completed_at INTEGER NOT NULL CHECK(typeof(completed_at) = 'integer' AND completed_at \u003e 0)\n)"
283 },
284 {
285 "Type": "table",
286 "Name": "roster_tokens",
287 "Table": "roster_tokens",
288 "SQL": "CREATE TABLE roster_tokens (\n token_hash BLOB PRIMARY KEY CHECK(typeof(token_hash) = 'blob' AND length(token_hash) = 32),\n consumer_id TEXT NOT NULL REFERENCES roster_consumers(consumer_id) ON DELETE RESTRICT,\n slot TEXT NOT NULL CHECK(slot IN ('current','previous')),\n issued_at INTEGER NOT NULL CHECK(typeof(issued_at) = 'integer' AND issued_at \u003e 0),\n expires_at INTEGER,\n UNIQUE(consumer_id,slot),\n CHECK((slot = 'current' AND expires_at IS NULL) OR\n (slot = 'previous' AND typeof(expires_at) = 'integer' AND expires_at \u003e issued_at AND expires_at - issued_at \u003c= 300))\n)"
289 },
290 {
291 "Type": "table",
292 "Name": "sessions",
293 "Table": "sessions",
294 "SQL": "CREATE TABLE sessions (\n token_hash TEXT PRIMARY KEY,\n subject TEXT NOT NULL,\n method TEXT NOT NULL DEFAULT '',\n auth_time TEXT NOT NULL DEFAULT '',\n created_at TEXT NOT NULL,\n expires_at TEXT NOT NULL\n)"
295 },
296 {
297 "Type": "table",
298 "Name": "sqlite_sequence",
299 "Table": "sqlite_sequence",
300 "SQL": "CREATE TABLE sqlite_sequence(name,seq)"
301 },
302 {
303 "Type": "table",
304 "Name": "team_instances",
305 "Table": "team_instances",
306 "SQL": "CREATE TABLE team_instances (\n team_id INTEGER NOT NULL REFERENCES teams(id) ON DELETE RESTRICT,\n app TEXT NOT NULL,\n origin TEXT NOT NULL UNIQUE,\n consumer_id TEXT NOT NULL UNIQUE,\n state TEXT NOT NULL CHECK(state IN ('pending', 'live', 'disabled')),\n PRIMARY KEY(team_id, app)\n)"
307 },
308 {
309 "Type": "table",
310 "Name": "teams",
311 "Table": "teams",
312 "SQL": "CREATE TABLE teams (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n sqid TEXT NOT NULL UNIQUE CHECK(length(sqid) BETWEEN 1 AND 64 AND sqid NOT GLOB '*[^a-zA-Z0-9]*'),\n label TEXT NOT NULL UNIQUE CHECK(length(label) BETWEEN 1 AND 63 AND label NOT GLOB '*[^a-z0-9-]*' AND substr(label,1,1) != '-' AND substr(label,-1,1) != '-'),\n sealed_name BLOB NOT NULL CHECK(typeof(sealed_name) = 'blob' AND length(sealed_name) BETWEEN 29 AND 284),\n created_at INTEGER NOT NULL CHECK(created_at \u003e 0),\n roster_epoch INTEGER NOT NULL DEFAULT 1 CHECK(typeof(roster_epoch) = 'integer' AND roster_epoch \u003e 0)\n)"
313 },
314 {
315 "Type": "table",
316 "Name": "verification_active",
317 "Table": "verification_active",
318 "SQL": "CREATE TABLE verification_active (\n consumer_id TEXT PRIMARY KEY REFERENCES roster_consumers(consumer_id),\n operation_id TEXT NOT NULL UNIQUE REFERENCES verification_attempts(operation_id)\n)"
319 },
320 {
321 "Type": "table",
322 "Name": "verification_attempts",
323 "Table": "verification_attempts",
324 "SQL": "CREATE TABLE verification_attempts (\n operation_id TEXT PRIMARY KEY CHECK(length(operation_id)=43),\n consumer_id TEXT NOT NULL REFERENCES roster_consumers(consumer_id),\n team_id INTEGER NOT NULL REFERENCES teams(id),\n app TEXT NOT NULL,\n origin TEXT NOT NULL,\n generation TEXT NOT NULL CHECK(length(generation)=43),\n record_sequence INTEGER NOT NULL CHECK(typeof(record_sequence)='integer' AND record_sequence\u003e0),\n record_digest BLOB NOT NULL CHECK(typeof(record_digest)='blob' AND length(record_digest)=32),\n expected_epoch INTEGER NOT NULL CHECK(typeof(expected_epoch)='integer' AND expected_epoch\u003e0),\n owner_ref TEXT NOT NULL CHECK(length(owner_ref)=29),\n issued_at INTEGER NOT NULL CHECK(typeof(issued_at)='integer' AND issued_at\u003e0),\n expires_at INTEGER NOT NULL CHECK(typeof(expires_at)='integer' AND expires_at\u003eissued_at AND expires_at-issued_at\u003c=600),\n authorization_digest BLOB NOT NULL CHECK(typeof(authorization_digest)='blob' AND length(authorization_digest)=32)\n)"
325 },
326 {
327 "Type": "table",
328 "Name": "verification_outcomes",
329 "Table": "verification_outcomes",
330 "SQL": "CREATE TABLE verification_outcomes (\n id INTEGER PRIMARY KEY AUTOINCREMENT,\n attempt_id TEXT NOT NULL REFERENCES verification_attempts(operation_id),\n operator_operation_id TEXT NOT NULL CHECK(length(operator_operation_id)=43),\n kind TEXT NOT NULL CHECK(kind IN ('opened','expired','activated')),\n completed_at INTEGER NOT NULL CHECK(typeof(completed_at)='integer' AND completed_at\u003e0),\n UNIQUE(attempt_id,operator_operation_id,kind)\n)"
331 },
332 {
333 "Type": "trigger",
334 "Name": "memberships_epoch_delete",
335 "Table": "memberships",
336 "SQL": "CREATE TRIGGER memberships_epoch_delete AFTER DELETE ON memberships BEGIN\n SELECT CASE WHEN (SELECT roster_epoch FROM teams WHERE id = OLD.team_id) = 9223372036854775807 THEN RAISE(ABORT,'roster epoch exhausted') END;\n UPDATE teams SET roster_epoch = roster_epoch + 1 WHERE id = OLD.team_id;\nEND"
337 },
338 {
339 "Type": "trigger",
340 "Name": "memberships_epoch_insert",
341 "Table": "memberships",
342 "SQL": "CREATE TRIGGER memberships_epoch_insert AFTER INSERT ON memberships BEGIN\n SELECT CASE WHEN (SELECT roster_epoch FROM teams WHERE id = NEW.team_id) = 9223372036854775807 THEN RAISE(ABORT,'roster epoch exhausted') END;\n UPDATE teams SET roster_epoch = roster_epoch + 1 WHERE id = NEW.team_id;\nEND"
343 },
344 {
345 "Type": "trigger",
346 "Name": "memberships_epoch_update",
347 "Table": "memberships",
348 "SQL": "CREATE TRIGGER memberships_epoch_update AFTER UPDATE ON memberships BEGIN\n SELECT CASE WHEN EXISTS(SELECT 1 FROM teams WHERE id IN (OLD.team_id,NEW.team_id) AND roster_epoch = 9223372036854775807) THEN RAISE(ABORT,'roster epoch exhausted') END;\n UPDATE teams SET roster_epoch = roster_epoch + 1 WHERE id IN (OLD.team_id,NEW.team_id);\nEND"
349 }
350]
351