@coffre/db 0.14.5 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/README.md +2 -1
  2. package/dist/change-records-_fKvahvs.js +55 -0
  3. package/dist/connect.d.ts +22 -10
  4. package/dist/connect.js +74 -12
  5. package/dist/database-CVteLhp1.d.ts +410 -0
  6. package/dist/{database-BadNeeN-.js → database-D55ENPX-.js} +46 -25
  7. package/dist/dialect.d.ts +4 -3
  8. package/dist/dialect.js +14 -5
  9. package/dist/grants.d.ts +4 -4
  10. package/dist/grants.js +4 -4
  11. package/dist/hyperdrive.d.ts +48 -23
  12. package/dist/hyperdrive.js +168 -91
  13. package/dist/index.d.ts +3 -3
  14. package/dist/index.js +1 -1
  15. package/dist/log-DaD7fyUq.d.ts +722 -0
  16. package/dist/log.d.ts +2 -622
  17. package/dist/log.js +178 -13
  18. package/dist/migrate.d.ts +43 -3
  19. package/dist/migrate.js +149 -29
  20. package/dist/migrations/postgres/0022_log_015.sql +672 -0
  21. package/dist/migrations/postgres/0023_change_path.sql +153 -0
  22. package/dist/migrations/postgres/0024_use_015.sql +556 -0
  23. package/dist/migrations/postgres/0025_app_change.sql +221 -0
  24. package/dist/migrations/postgres/0026_issue_lock.sql +106 -0
  25. package/dist/migrations/postgres/0027_retention.sql +118 -0
  26. package/dist/migrations/postgres/0028_use_stalls.sql +594 -0
  27. package/dist/migrations/postgres/0029_use_objects.sql +887 -0
  28. package/dist/migrations/postgres/0030_unarchive_restores.sql +259 -0
  29. package/dist/migrations/postgres/0031_app_read.sql +65 -0
  30. package/dist/migrations/postgres/0032_secrets_live_index.sql +4 -0
  31. package/dist/migrations/postgres/0033_use_generations.sql +582 -0
  32. package/dist/migrations/postgres/0034_vault_credentials.sql +153 -0
  33. package/dist/migrations/postgres/0035_first_days.sql +3 -0
  34. package/dist/migrations/postgres/0036_vault_issues.sql +91 -0
  35. package/dist/migrations/postgres/0037_vault_bindings.sql +271 -0
  36. package/dist/migrations/postgres/0040_binding_origin.sql +159 -0
  37. package/dist/migrations/postgres/0041_cutover.sql +132 -0
  38. package/dist/migrations/postgres/0042_sign_in_index.sql +7 -0
  39. package/dist/migrations/postgres/0043_issue_revoke_index.sql +4 -0
  40. package/dist/migrations/postgres/0044_use_by_name.sql +705 -0
  41. package/dist/migrations/postgres/0045_decide_first.sql +878 -0
  42. package/dist/migrations/postgres/0046_way_in_uses.sql +1149 -0
  43. package/dist/migrations/postgres/0047_cutover_finish.sql +268 -0
  44. package/dist/migrations/postgres/0048_use_batch.sql +59 -0
  45. package/dist/migrations/postgres/0049_reads.sql +171 -0
  46. package/dist/migrations/postgres/meta/0022_snapshot.json +3831 -0
  47. package/dist/migrations/postgres/meta/0023_snapshot.json +3831 -0
  48. package/dist/migrations/postgres/meta/0024_snapshot.json +3831 -0
  49. package/dist/migrations/postgres/meta/0025_snapshot.json +3831 -0
  50. package/dist/migrations/postgres/meta/0026_snapshot.json +3831 -0
  51. package/dist/migrations/postgres/meta/0027_snapshot.json +3853 -0
  52. package/dist/migrations/postgres/meta/0028_snapshot.json +3853 -0
  53. package/dist/migrations/postgres/meta/0029_snapshot.json +3859 -0
  54. package/dist/migrations/postgres/meta/0030_snapshot.json +3859 -0
  55. package/dist/migrations/postgres/meta/0031_snapshot.json +3859 -0
  56. package/dist/migrations/postgres/meta/0032_snapshot.json +3875 -0
  57. package/dist/migrations/postgres/meta/0033_snapshot.json +3875 -0
  58. package/dist/migrations/postgres/meta/0034_snapshot.json +3875 -0
  59. package/dist/migrations/postgres/meta/0035_snapshot.json +3875 -0
  60. package/dist/migrations/postgres/meta/0036_snapshot.json +3875 -0
  61. package/dist/migrations/postgres/meta/0037_snapshot.json +3875 -0
  62. package/dist/migrations/postgres/meta/0038_snapshot.json +3881 -0
  63. package/dist/migrations/postgres/meta/0039_snapshot.json +3881 -0
  64. package/dist/migrations/postgres/meta/0040_snapshot.json +3931 -0
  65. package/dist/migrations/postgres/meta/0041_snapshot.json +3981 -0
  66. package/dist/migrations/postgres/meta/0042_snapshot.json +3981 -0
  67. package/dist/migrations/postgres/meta/0043_snapshot.json +3981 -0
  68. package/dist/migrations/postgres/meta/0044_snapshot.json +3991 -0
  69. package/dist/migrations/postgres/meta/0045_snapshot.json +3997 -0
  70. package/dist/migrations/postgres/meta/0046_snapshot.json +3997 -0
  71. package/dist/migrations/postgres/meta/0047_snapshot.json +4234 -0
  72. package/dist/migrations/postgres/meta/_journal.json +182 -0
  73. package/dist/migrations/sqlite/0018_log_015.sql +84 -0
  74. package/dist/migrations/sqlite/0019_retention.sql +2 -0
  75. package/dist/migrations/sqlite/0020_ended_references.sql +1 -0
  76. package/dist/migrations/sqlite/0021_secrets_live_index.sql +1 -0
  77. package/dist/migrations/sqlite/0022_binding_origin.sql +1 -0
  78. package/dist/migrations/sqlite/0023_sign_in_index.sql +2 -0
  79. package/dist/migrations/sqlite/0024_issue_revoke_index.sql +2 -0
  80. package/dist/migrations/sqlite/0025_way_in_uses.sql +42 -0
  81. package/dist/migrations/sqlite/0026_cutover_finish.sql +11 -0
  82. package/dist/migrations/sqlite/0027_reads.sql +38 -0
  83. package/dist/migrations/sqlite/meta/0018_snapshot.json +3529 -0
  84. package/dist/migrations/sqlite/meta/0019_snapshot.json +3538 -0
  85. package/dist/migrations/sqlite/meta/0020_snapshot.json +3545 -0
  86. package/dist/migrations/sqlite/meta/0021_snapshot.json +3553 -0
  87. package/dist/migrations/sqlite/meta/0022_snapshot.json +3560 -0
  88. package/dist/migrations/sqlite/meta/0023_snapshot.json +3579 -0
  89. package/dist/migrations/sqlite/meta/0024_snapshot.json +3598 -0
  90. package/dist/migrations/sqlite/meta/0025_snapshot.json +3609 -0
  91. package/dist/migrations/sqlite/meta/0026_snapshot.json +3616 -0
  92. package/dist/migrations/sqlite/meta/0027_snapshot.json +3834 -0
  93. package/dist/migrations/sqlite/meta/_journal.json +70 -0
  94. package/dist/platform-Y3gICK6n.d.ts +58 -0
  95. package/dist/portable.d.ts +2 -2
  96. package/dist/postgres-BI3xTnyw.js +1718 -0
  97. package/dist/postgres-platform-node.d.ts +14 -0
  98. package/dist/postgres-platform-node.js +21 -0
  99. package/dist/postgres-platform-workerd.d.ts +61 -0
  100. package/dist/postgres-platform-workerd.js +163 -0
  101. package/dist/{schema-BfQEBqFv.d.ts → schema-DgoPqqsI.d.ts} +1326 -7
  102. package/dist/schema-sqlite.d.ts +1306 -6
  103. package/dist/schema-sqlite.js +154 -18
  104. package/dist/schema-version.d.ts +1 -1
  105. package/dist/schema-version.js +254 -2
  106. package/dist/schema.d.ts +2 -2
  107. package/dist/schema.js +226 -20
  108. package/package.json +13 -5
  109. package/src/active-subject.ts +9 -0
  110. package/src/change-records.ts +38 -0
  111. package/src/connect.ts +67 -13
  112. package/src/database.ts +67 -51
  113. package/src/dialect.ts +17 -8
  114. package/src/grants.ts +3 -3
  115. package/src/hyperdrive.ts +181 -104
  116. package/src/log.ts +196 -15
  117. package/src/migrate.ts +157 -30
  118. package/src/migrations/postgres/0022_log_015.sql +672 -0
  119. package/src/migrations/postgres/0023_change_path.sql +153 -0
  120. package/src/migrations/postgres/0024_use_015.sql +556 -0
  121. package/src/migrations/postgres/0025_app_change.sql +221 -0
  122. package/src/migrations/postgres/0026_issue_lock.sql +106 -0
  123. package/src/migrations/postgres/0027_retention.sql +118 -0
  124. package/src/migrations/postgres/0028_use_stalls.sql +594 -0
  125. package/src/migrations/postgres/0029_use_objects.sql +887 -0
  126. package/src/migrations/postgres/0030_unarchive_restores.sql +259 -0
  127. package/src/migrations/postgres/0031_app_read.sql +65 -0
  128. package/src/migrations/postgres/0032_secrets_live_index.sql +4 -0
  129. package/src/migrations/postgres/0033_use_generations.sql +582 -0
  130. package/src/migrations/postgres/0034_vault_credentials.sql +153 -0
  131. package/src/migrations/postgres/0035_first_days.sql +3 -0
  132. package/src/migrations/postgres/0036_vault_issues.sql +91 -0
  133. package/src/migrations/postgres/0037_vault_bindings.sql +271 -0
  134. package/src/migrations/postgres/0040_binding_origin.sql +159 -0
  135. package/src/migrations/postgres/0041_cutover.sql +132 -0
  136. package/src/migrations/postgres/0042_sign_in_index.sql +7 -0
  137. package/src/migrations/postgres/0043_issue_revoke_index.sql +4 -0
  138. package/src/migrations/postgres/0044_use_by_name.sql +705 -0
  139. package/src/migrations/postgres/0045_decide_first.sql +878 -0
  140. package/src/migrations/postgres/0046_way_in_uses.sql +1149 -0
  141. package/src/migrations/postgres/0047_cutover_finish.sql +268 -0
  142. package/src/migrations/postgres/0048_use_batch.sql +59 -0
  143. package/src/migrations/postgres/0049_reads.sql +171 -0
  144. package/src/migrations/postgres/meta/0022_snapshot.json +3831 -0
  145. package/src/migrations/postgres/meta/0023_snapshot.json +3831 -0
  146. package/src/migrations/postgres/meta/0024_snapshot.json +3831 -0
  147. package/src/migrations/postgres/meta/0025_snapshot.json +3831 -0
  148. package/src/migrations/postgres/meta/0026_snapshot.json +3831 -0
  149. package/src/migrations/postgres/meta/0027_snapshot.json +3853 -0
  150. package/src/migrations/postgres/meta/0028_snapshot.json +3853 -0
  151. package/src/migrations/postgres/meta/0029_snapshot.json +3859 -0
  152. package/src/migrations/postgres/meta/0030_snapshot.json +3859 -0
  153. package/src/migrations/postgres/meta/0031_snapshot.json +3859 -0
  154. package/src/migrations/postgres/meta/0032_snapshot.json +3875 -0
  155. package/src/migrations/postgres/meta/0033_snapshot.json +3875 -0
  156. package/src/migrations/postgres/meta/0034_snapshot.json +3875 -0
  157. package/src/migrations/postgres/meta/0035_snapshot.json +3875 -0
  158. package/src/migrations/postgres/meta/0036_snapshot.json +3875 -0
  159. package/src/migrations/postgres/meta/0037_snapshot.json +3875 -0
  160. package/src/migrations/postgres/meta/0038_snapshot.json +3881 -0
  161. package/src/migrations/postgres/meta/0039_snapshot.json +3881 -0
  162. package/src/migrations/postgres/meta/0040_snapshot.json +3931 -0
  163. package/src/migrations/postgres/meta/0041_snapshot.json +3981 -0
  164. package/src/migrations/postgres/meta/0042_snapshot.json +3981 -0
  165. package/src/migrations/postgres/meta/0043_snapshot.json +3981 -0
  166. package/src/migrations/postgres/meta/0044_snapshot.json +3991 -0
  167. package/src/migrations/postgres/meta/0045_snapshot.json +3997 -0
  168. package/src/migrations/postgres/meta/0046_snapshot.json +3997 -0
  169. package/src/migrations/postgres/meta/0047_snapshot.json +4234 -0
  170. package/src/migrations/postgres/meta/_journal.json +182 -0
  171. package/src/migrations/sqlite/0018_log_015.sql +84 -0
  172. package/src/migrations/sqlite/0019_retention.sql +2 -0
  173. package/src/migrations/sqlite/0020_ended_references.sql +1 -0
  174. package/src/migrations/sqlite/0021_secrets_live_index.sql +1 -0
  175. package/src/migrations/sqlite/0022_binding_origin.sql +1 -0
  176. package/src/migrations/sqlite/0023_sign_in_index.sql +2 -0
  177. package/src/migrations/sqlite/0024_issue_revoke_index.sql +2 -0
  178. package/src/migrations/sqlite/0025_way_in_uses.sql +42 -0
  179. package/src/migrations/sqlite/0026_cutover_finish.sql +11 -0
  180. package/src/migrations/sqlite/0027_reads.sql +38 -0
  181. package/src/migrations/sqlite/meta/0018_snapshot.json +3529 -0
  182. package/src/migrations/sqlite/meta/0019_snapshot.json +3538 -0
  183. package/src/migrations/sqlite/meta/0020_snapshot.json +3545 -0
  184. package/src/migrations/sqlite/meta/0021_snapshot.json +3553 -0
  185. package/src/migrations/sqlite/meta/0022_snapshot.json +3560 -0
  186. package/src/migrations/sqlite/meta/0023_snapshot.json +3579 -0
  187. package/src/migrations/sqlite/meta/0024_snapshot.json +3598 -0
  188. package/src/migrations/sqlite/meta/0025_snapshot.json +3609 -0
  189. package/src/migrations/sqlite/meta/0026_snapshot.json +3616 -0
  190. package/src/migrations/sqlite/meta/0027_snapshot.json +3834 -0
  191. package/src/migrations/sqlite/meta/_journal.json +70 -0
  192. package/src/postgres-js/README.md +183 -0
  193. package/src/postgres-js/UNLICENSE +24 -0
  194. package/src/postgres-js/bytes.ts +89 -0
  195. package/src/postgres-js/connection.ts +882 -0
  196. package/src/postgres-js/errors.ts +84 -0
  197. package/src/postgres-js/index.ts +516 -0
  198. package/src/postgres-js/platform.node.ts +29 -0
  199. package/src/postgres-js/platform.ts +60 -0
  200. package/src/postgres-js/platform.workerd.ts +225 -0
  201. package/src/postgres-js/query.ts +123 -0
  202. package/src/postgres-js/queue.ts +42 -0
  203. package/src/postgres-js/result.ts +46 -0
  204. package/src/postgres-js/types.ts +52 -0
  205. package/src/postgres.ts +375 -26
  206. package/src/schema-version.ts +2 -2
  207. package/src/schema.sqlite.ts +198 -7
  208. package/src/schema.ts +291 -6
  209. package/src/verify-runtime.ts +18 -29
  210. package/LICENSE +0 -21
  211. package/dist/database-wq1AVRAP.d.ts +0 -73
  212. package/dist/postgres-Bmar8y0q.js +0 -29
  213. package/dist/relations-BfR3JjT1.js +0 -38
  214. package/src/relations.ts +0 -40
@@ -155,6 +155,188 @@
155
155
  "when": 1793035191911,
156
156
  "tag": "0021_prune_vault_releases",
157
157
  "breakpoints": true
158
+ },
159
+ {
160
+ "idx": 22,
161
+ "version": "7",
162
+ "when": 1793068924881,
163
+ "tag": "0022_log_015",
164
+ "breakpoints": true
165
+ },
166
+ {
167
+ "idx": 23,
168
+ "version": "7",
169
+ "when": 1793090000000,
170
+ "tag": "0023_change_path",
171
+ "breakpoints": true
172
+ },
173
+ {
174
+ "idx": 24,
175
+ "version": "7",
176
+ "when": 1793094000246,
177
+ "tag": "0024_use_015",
178
+ "breakpoints": true
179
+ },
180
+ {
181
+ "idx": 25,
182
+ "version": "7",
183
+ "when": 1793100000000,
184
+ "tag": "0025_app_change",
185
+ "breakpoints": true
186
+ },
187
+ {
188
+ "idx": 26,
189
+ "version": "7",
190
+ "when": 1793110000000,
191
+ "tag": "0026_issue_lock",
192
+ "breakpoints": true
193
+ },
194
+ {
195
+ "idx": 27,
196
+ "version": "7",
197
+ "when": 1793120000000,
198
+ "tag": "0027_retention",
199
+ "breakpoints": true
200
+ },
201
+ {
202
+ "idx": 28,
203
+ "version": "7",
204
+ "when": 1793130000000,
205
+ "tag": "0028_use_stalls",
206
+ "breakpoints": true
207
+ },
208
+ {
209
+ "idx": 29,
210
+ "version": "7",
211
+ "when": 1793140000000,
212
+ "tag": "0029_use_objects",
213
+ "breakpoints": true
214
+ },
215
+ {
216
+ "idx": 30,
217
+ "version": "7",
218
+ "when": 1793150000000,
219
+ "tag": "0030_unarchive_restores",
220
+ "breakpoints": true
221
+ },
222
+ {
223
+ "idx": 31,
224
+ "version": "7",
225
+ "when": 1793160000000,
226
+ "tag": "0031_app_read",
227
+ "breakpoints": true
228
+ },
229
+ {
230
+ "idx": 32,
231
+ "version": "7",
232
+ "when": 1793180483207,
233
+ "tag": "0032_secrets_live_index",
234
+ "breakpoints": true
235
+ },
236
+ {
237
+ "idx": 33,
238
+ "version": "7",
239
+ "when": 1793190483207,
240
+ "tag": "0033_use_generations",
241
+ "breakpoints": true
242
+ },
243
+ {
244
+ "idx": 34,
245
+ "version": "7",
246
+ "when": 1793200483207,
247
+ "tag": "0034_vault_credentials",
248
+ "breakpoints": true
249
+ },
250
+ {
251
+ "idx": 35,
252
+ "version": "7",
253
+ "when": 1793210483207,
254
+ "tag": "0035_first_days",
255
+ "breakpoints": true
256
+ },
257
+ {
258
+ "idx": 36,
259
+ "version": "7",
260
+ "when": 1793220483207,
261
+ "tag": "0036_vault_issues",
262
+ "breakpoints": true
263
+ },
264
+ {
265
+ "idx": 37,
266
+ "version": "7",
267
+ "when": 1793230483207,
268
+ "tag": "0037_vault_bindings",
269
+ "breakpoints": true
270
+ },
271
+ {
272
+ "idx": 38,
273
+ "version": "7",
274
+ "when": 1793247589162,
275
+ "tag": "0040_binding_origin",
276
+ "breakpoints": true
277
+ },
278
+ {
279
+ "idx": 39,
280
+ "version": "7",
281
+ "when": 1793270313298,
282
+ "tag": "0041_cutover",
283
+ "breakpoints": true
284
+ },
285
+ {
286
+ "idx": 40,
287
+ "version": "7",
288
+ "when": 1793302884510,
289
+ "tag": "0042_sign_in_index",
290
+ "breakpoints": true
291
+ },
292
+ {
293
+ "idx": 41,
294
+ "version": "7",
295
+ "when": 1793306932805,
296
+ "tag": "0043_issue_revoke_index",
297
+ "breakpoints": true
298
+ },
299
+ {
300
+ "idx": 42,
301
+ "version": "7",
302
+ "when": 1793316932805,
303
+ "tag": "0044_use_by_name",
304
+ "breakpoints": true
305
+ },
306
+ {
307
+ "idx": 43,
308
+ "version": "7",
309
+ "when": 1793326932805,
310
+ "tag": "0045_decide_first",
311
+ "breakpoints": true
312
+ },
313
+ {
314
+ "idx": 44,
315
+ "version": "7",
316
+ "when": 1793352372315,
317
+ "tag": "0046_way_in_uses",
318
+ "breakpoints": true
319
+ },
320
+ {
321
+ "idx": 45,
322
+ "version": "7",
323
+ "when": 1793372629862,
324
+ "tag": "0047_cutover_finish",
325
+ "breakpoints": true
326
+ },
327
+ {
328
+ "idx": 46,
329
+ "version": "7",
330
+ "when": 1793390000000,
331
+ "tag": "0048_use_batch",
332
+ "breakpoints": true
333
+ },
334
+ {
335
+ "idx": 47,
336
+ "version": "7",
337
+ "when": 1793445614633,
338
+ "tag": "0049_reads",
339
+ "breakpoints": true
158
340
  }
159
341
  ]
160
342
  }
@@ -0,0 +1,84 @@
1
+ -- 0.15's log (the Postgres migration, 0022_log_015, says what each part is): its tables and the seals, for tests and local development. SQLite has one writer, so the fence is implicit and nothing is partitioned; it has no functions and no logins. It only adds. Each seal's check is on its column: added with the column, it rebuilds no table.
2
+ CREATE TABLE `log_bulk` (
3
+ `principal` text NOT NULL,
4
+ `secret` text NOT NULL,
5
+ `last` integer NOT NULL,
6
+ PRIMARY KEY(`principal`, `secret`)
7
+ );
8
+ --> statement-breakpoint
9
+ CREATE TABLE `log_changes` (
10
+ `number` integer PRIMARY KEY NOT NULL,
11
+ `at` integer NOT NULL,
12
+ `request_id` text NOT NULL,
13
+ `object` text NOT NULL,
14
+ `actor` text NOT NULL,
15
+ `payload` text NOT NULL,
16
+ `seal` blob,
17
+ `mac` blob NOT NULL,
18
+ CONSTRAINT "log_changes_seal_check" CHECK("log_changes"."seal" IS NULL OR octet_length("log_changes"."seal") = 16),
19
+ CONSTRAINT "log_changes_mac_check" CHECK(octet_length("log_changes"."mac") = 16)
20
+ );
21
+ --> statement-breakpoint
22
+ CREATE INDEX `log_changes_object_idx` ON `log_changes` (`object`,`number`);--> statement-breakpoint
23
+ CREATE UNIQUE INDEX `log_changes_request_id_key` ON `log_changes` (`request_id`);--> statement-breakpoint
24
+ CREATE TABLE `log_checkpoints` (
25
+ `upto` integer PRIMARY KEY NOT NULL,
26
+ `at` integer NOT NULL,
27
+ `at_floor` integer NOT NULL,
28
+ `changes_size` integer NOT NULL,
29
+ `changes_root` blob NOT NULL,
30
+ `changes_note` text NOT NULL,
31
+ `uses_size` integer NOT NULL,
32
+ `uses_root` blob NOT NULL,
33
+ `uses_note` text NOT NULL,
34
+ CONSTRAINT "log_checkpoints_changes_root_check" CHECK(octet_length("log_checkpoints"."changes_root") = 32),
35
+ CONSTRAINT "log_checkpoints_uses_root_check" CHECK(octet_length("log_checkpoints"."uses_root") = 32)
36
+ );
37
+ --> statement-breakpoint
38
+ CREATE TABLE `log_fence` (
39
+ `only_row` integer PRIMARY KEY DEFAULT true NOT NULL,
40
+ `at_floor` integer NOT NULL,
41
+ CONSTRAINT "log_fence_only_row_check" CHECK("log_fence"."only_row")
42
+ );
43
+ --> statement-breakpoint
44
+ CREATE TABLE `log_tiles` (
45
+ `tree` text NOT NULL,
46
+ `level` integer NOT NULL,
47
+ `leaf` integer NOT NULL,
48
+ `hashes` blob NOT NULL,
49
+ PRIMARY KEY(`tree`, `level`, `leaf`),
50
+ CONSTRAINT "log_tiles_tree_check" CHECK("log_tiles"."tree" IN ('changes', 'uses')),
51
+ CONSTRAINT "log_tiles_level_check" CHECK("log_tiles"."level" BETWEEN 0 AND 7),
52
+ CONSTRAINT "log_tiles_leaf_check" CHECK("log_tiles"."leaf" >= 0 AND (("log_tiles"."level" = 7 AND "log_tiles"."leaf" = 0) OR ("log_tiles"."level" < 7 AND "log_tiles"."leaf" % (1 << (8 * ("log_tiles"."level" + 1))) = 0))),
53
+ CONSTRAINT "log_tiles_hashes_check" CHECK(octet_length("log_tiles"."hashes") BETWEEN 32 AND 8192 AND octet_length("log_tiles"."hashes") % 32 = 0)
54
+ );
55
+ --> statement-breakpoint
56
+ CREATE TABLE `log_uses` (
57
+ `number` integer NOT NULL,
58
+ `at` integer NOT NULL,
59
+ `request_id` integer NOT NULL,
60
+ `credential` text NOT NULL,
61
+ `secret` text NOT NULL,
62
+ `purpose` integer NOT NULL,
63
+ `mac` blob NOT NULL,
64
+ `place` text,
65
+ CONSTRAINT "log_uses_mac_check" CHECK(octet_length("log_uses"."mac") = 16)
66
+ );
67
+ --> statement-breakpoint
68
+ CREATE UNIQUE INDEX `log_uses_request_idx` ON `log_uses` (`at`,`request_id`);--> statement-breakpoint
69
+ CREATE TABLE `log_config` (
70
+ `name` text PRIMARY KEY NOT NULL,
71
+ `value` text NOT NULL,
72
+ `seal` blob,
73
+ CONSTRAINT "log_config_name_check" CHECK("log_config"."name" IN ('policy', 'roles')),
74
+ CONSTRAINT "log_config_value_check" CHECK(json_valid("log_config"."value")),
75
+ CONSTRAINT "log_config_seal_check" CHECK("log_config"."seal" IS NULL OR octet_length("log_config"."seal") = 16)
76
+ );
77
+ --> statement-breakpoint
78
+ ALTER TABLE `credentials` ADD COLUMN `seal` blob CONSTRAINT "credentials_seal_check" CHECK("seal" IS NULL OR octet_length("seal") = 16);--> statement-breakpoint
79
+ ALTER TABLE `environments` ADD COLUMN `protected` integer;--> statement-breakpoint
80
+ ALTER TABLE `environments` ADD COLUMN `seal` blob CONSTRAINT "environments_seal_check" CHECK("seal" IS NULL OR octet_length("seal") = 16);--> statement-breakpoint
81
+ ALTER TABLE `secrets` ADD COLUMN `seal` blob CONSTRAINT "secrets_seal_check" CHECK("seal" IS NULL OR octet_length("seal") = 16);--> statement-breakpoint
82
+ ALTER TABLE `service_bindings` ADD COLUMN `seal` blob CONSTRAINT "service_bindings_seal_check" CHECK("seal" IS NULL OR octet_length("seal") = 16);--> statement-breakpoint
83
+ ALTER TABLE `vault_members` ADD COLUMN `seal` blob CONSTRAINT "vault_members_seal_check" CHECK("seal" IS NULL OR octet_length("seal") = 16);--> statement-breakpoint
84
+ INSERT INTO `log_fence` (`only_row`, `at_floor`) VALUES (1, CAST(unixepoch('subsec') * 1000 AS INTEGER) - 3000);
@@ -0,0 +1,2 @@
1
+ -- 0.15's retention (the Postgres migration, 0027_retention, says what it is): a day's cut, the first checkpoint whose floor of at is past the day's end, by an index. SQLite has no partitions and no functions: retention deletes rows (log-store.ts).
2
+ CREATE INDEX `log_checkpoints_floor_idx` ON `log_checkpoints` (`at_floor`,`upto`);
@@ -0,0 +1 @@
1
+ ALTER TABLE `secret_references` ADD `ended_at` integer;
@@ -0,0 +1 @@
1
+ CREATE INDEX `secrets_live_idx` ON `secrets` (`environment_id`) WHERE `archived_at` IS NULL;
@@ -0,0 +1 @@
1
+ ALTER TABLE `service_bindings` ADD `origin` text;
@@ -0,0 +1,2 @@
1
+ CREATE INDEX `log_changes_sign_in_idx` ON `log_changes` (`at`,`number`) WHERE instr("log_changes"."payload", '"signIn":{') > 0;--> statement-breakpoint
2
+ CREATE INDEX `log_changes_sign_in_actor_idx` ON `log_changes` (`actor`,`at`,`number`) WHERE instr("log_changes"."payload", '"signIn":{') > 0;
@@ -0,0 +1,2 @@
1
+ CREATE INDEX `log_changes_issue_revoke_idx` ON `log_changes` (`at`,`number`) WHERE ((instr("log_changes"."payload", '{"caller":"') = 1 AND instr("log_changes"."payload", '"issue":{"by":"') > 0) OR (instr("log_changes"."payload", '{"op":"credential.revoke",') = 1 AND instr("log_changes"."payload", '"reason":"revoke"') > 0) OR (instr("log_changes"."payload", '{"op":"credential.revoke",') = 1 AND instr("log_changes"."payload", '"reason":"sign_out"') > 0));--> statement-breakpoint
2
+ CREATE INDEX `log_changes_issue_revoke_actor_idx` ON `log_changes` (`actor`,`at`,`number`) WHERE ((instr("log_changes"."payload", '{"caller":"') = 1 AND instr("log_changes"."payload", '"issue":{"by":"') > 0) OR (instr("log_changes"."payload", '{"op":"credential.revoke",') = 1 AND instr("log_changes"."payload", '"reason":"revoke"') > 0) OR (instr("log_changes"."payload", '{"op":"credential.revoke",') = 1 AND instr("log_changes"."payload", '"reason":"sign_out"') > 0));
@@ -0,0 +1,42 @@
1
+ -- MCP connections are sealed objects of 0.15's log (T147; postgres/0046_way_in_uses.sql): their seal. SQLite adds a check by making the table again.
2
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
3
+ CREATE TABLE `__new_mcp_connections` (
4
+ `id` text PRIMARY KEY NOT NULL,
5
+ `auth_mac` blob NOT NULL,
6
+ `principal` text NOT NULL,
7
+ `generation` integer NOT NULL,
8
+ `client_id` text NOT NULL,
9
+ `client_name` text NOT NULL,
10
+ `client_host` text,
11
+ `registration` text NOT NULL,
12
+ `scopes` text NOT NULL,
13
+ `redirect_uri` text NOT NULL,
14
+ `code_hash` blob,
15
+ `code_challenge` text,
16
+ `code_expires_at` integer,
17
+ `refresh_hash` blob,
18
+ `refresh_previous_hash` blob,
19
+ `expires_at` integer NOT NULL,
20
+ `created_at` integer DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)) NOT NULL,
21
+ `last_used_at` integer,
22
+ `last_used_ip` text,
23
+ `revoked_at` integer,
24
+ `revoked_by` text,
25
+ `seal` blob,
26
+ FOREIGN KEY (`principal`) REFERENCES `vault_members`(`principal`) ON UPDATE no action ON DELETE restrict,
27
+ CONSTRAINT "mcp_connections_seal_check" CHECK("__new_mcp_connections"."seal" IS NULL OR octet_length("__new_mcp_connections"."seal") = 16),
28
+ CONSTRAINT "mcp_connections_principal_check" CHECK("__new_mcp_connections"."principal" LIKE 'user:%'),
29
+ CONSTRAINT "mcp_connections_registration_check" CHECK("__new_mcp_connections"."registration" IN ('cimd', 'dcr')),
30
+ CONSTRAINT "mcp_connections_auth_mac_check" CHECK(octet_length("__new_mcp_connections"."auth_mac") = 32),
31
+ CONSTRAINT "mcp_connections_code_hash_check" CHECK("__new_mcp_connections"."code_hash" IS NULL OR octet_length("__new_mcp_connections"."code_hash") = 32),
32
+ CONSTRAINT "mcp_connections_refresh_hash_check" CHECK("__new_mcp_connections"."refresh_hash" IS NULL OR octet_length("__new_mcp_connections"."refresh_hash") = 32)
33
+ );
34
+ --> statement-breakpoint
35
+ INSERT INTO `__new_mcp_connections`("id", "auth_mac", "principal", "generation", "client_id", "client_name", "client_host", "registration", "scopes", "redirect_uri", "code_hash", "code_challenge", "code_expires_at", "refresh_hash", "refresh_previous_hash", "expires_at", "created_at", "last_used_at", "last_used_ip", "revoked_at", "revoked_by") SELECT "id", "auth_mac", "principal", "generation", "client_id", "client_name", "client_host", "registration", "scopes", "redirect_uri", "code_hash", "code_challenge", "code_expires_at", "refresh_hash", "refresh_previous_hash", "expires_at", "created_at", "last_used_at", "last_used_ip", "revoked_at", "revoked_by" FROM `mcp_connections`;--> statement-breakpoint
36
+ DROP TABLE `mcp_connections`;--> statement-breakpoint
37
+ ALTER TABLE `__new_mcp_connections` RENAME TO `mcp_connections`;--> statement-breakpoint
38
+ PRAGMA foreign_keys=ON;--> statement-breakpoint
39
+ CREATE INDEX `mcp_connections_refresh_previous_idx` ON `mcp_connections` (`refresh_previous_hash`);--> statement-breakpoint
40
+ CREATE INDEX `mcp_connections_live_idx` ON `mcp_connections` (`principal`,`expires_at`) WHERE "mcp_connections"."revoked_at" IS NULL;--> statement-breakpoint
41
+ CREATE UNIQUE INDEX `mcp_connections_code_hash_key` ON `mcp_connections` (`code_hash`);--> statement-breakpoint
42
+ CREATE UNIQUE INDEX `mcp_connections_refresh_hash_key` ON `mcp_connections` (`refresh_hash`);
@@ -0,0 +1,11 @@
1
+ -- 0.14's writes refused once the cutover is there (the Postgres migration, 0047_cutover_finish, says why): the column every entry a writer under 0.15's log appends carries, and the trigger. SQLite has one writer and no functions: the cutover's change is found by its object's key, `log_object('log', 'cutover')` as the vault computes it (log-entry.ts, CUTOVER_OBJECT).
2
+ ALTER TABLE `audit_log` ADD `log015` integer;
3
+ --> statement-breakpoint
4
+ CREATE TRIGGER `audit_log_refuse_old` BEFORE INSERT ON `audit_log` FOR EACH ROW
5
+ WHEN NEW.`decision` = 'allow' AND NEW.`log015` IS NULL AND NEW.`action` NOT LIKE 'audit.%' AND NEW.`action` NOT IN (
6
+ 'credential.use', 'token.use', 'secret.read', 'secret.use', 'secret.list', 'secret.history', 'secret.version', 'missing.list', 'personal.list',
7
+ 'roles.list', 'roles.preview', 'mcp.read', 'mcp.view', 'key.check', 'key.intent', 'workload.alert', 'vault.tampered'
8
+ ) AND EXISTS (SELECT 1 FROM `log_changes` WHERE `object` = '60b3bfb2-d45c-96d7-5c0c-be2d45fc15dc')
9
+ BEGIN
10
+ SELECT RAISE(ABORT, '0.15''s log is cut over from 0.14: every write of 0.14''s after it is refused (an isolate of the earlier release still serving: ask again)');
11
+ END;
@@ -0,0 +1,38 @@
1
+ -- The audit pages' reads, a sealed projection of 0.15's uses (T166; postgres 0049_reads). SQLite has one writer and no partitions: the projector writes these directly.
2
+ CREATE TABLE `log_read_days` (
3
+ `principal` text NOT NULL,
4
+ `day` integer NOT NULL,
5
+ PRIMARY KEY(`principal`, `day`)
6
+ );
7
+ --> statement-breakpoint
8
+ CREATE TABLE `log_reads` (
9
+ `number` integer NOT NULL,
10
+ `at` integer NOT NULL,
11
+ `credential` text NOT NULL,
12
+ `purpose` integer NOT NULL,
13
+ `principal` text NOT NULL,
14
+ `secret` text NOT NULL,
15
+ `environment` text NOT NULL,
16
+ `project` text NOT NULL,
17
+ `place` text,
18
+ `source` text,
19
+ `source_environment` text,
20
+ `source_project` text,
21
+ `version` text,
22
+ `mac` blob NOT NULL,
23
+ CONSTRAINT "log_reads_mac_check" CHECK(octet_length("log_reads"."mac") = 16)
24
+ );
25
+ --> statement-breakpoint
26
+ CREATE UNIQUE INDEX `log_reads_number_idx` ON `log_reads` (`at`,`number`);--> statement-breakpoint
27
+ CREATE INDEX `log_reads_principal_idx` ON `log_reads` (`principal`,`at`,`number`);--> statement-breakpoint
28
+ CREATE TABLE `log_reads_cursor` (
29
+ `only_row` integer PRIMARY KEY DEFAULT true NOT NULL,
30
+ `through` integer NOT NULL,
31
+ `pair` integer NOT NULL,
32
+ `at` integer NOT NULL,
33
+ `mac` blob,
34
+ CONSTRAINT "log_reads_cursor_only_row_check" CHECK("log_reads_cursor"."only_row"),
35
+ CONSTRAINT "log_reads_cursor_mac_check" CHECK("log_reads_cursor"."mac" IS NULL OR octet_length("log_reads_cursor"."mac") = 16)
36
+ );
37
+ --> statement-breakpoint
38
+ INSERT INTO `log_reads_cursor` (`only_row`, `through`, `pair`, `at`) VALUES (1, 0, 0, 0);