@coffre/db 0.7.0 → 0.8.1

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.
@@ -64,6 +64,13 @@
64
64
  "when": 1792255559691,
65
65
  "tag": "0008_recipes",
66
66
  "breakpoints": true
67
+ },
68
+ {
69
+ "idx": 9,
70
+ "version": "7",
71
+ "when": 1792281879553,
72
+ "tag": "0009_handles",
73
+ "breakpoints": true
67
74
  }
68
75
  ]
69
76
  }
@@ -0,0 +1,36 @@
1
+ PRAGMA foreign_keys=OFF;--> statement-breakpoint
2
+ CREATE TABLE `__new_credentials` (
3
+ `id` text PRIMARY KEY NOT NULL,
4
+ `kind` text NOT NULL,
5
+ `auth_mac` blob NOT NULL,
6
+ `token_hash` blob NOT NULL,
7
+ `token_hint` text NOT NULL,
8
+ `generation` integer NOT NULL,
9
+ `principal` text NOT NULL,
10
+ `identity_id` text,
11
+ `scope` text,
12
+ `label` text,
13
+ `created_at` integer DEFAULT (CAST(unixepoch('subsec') * 1000 AS INTEGER)) NOT NULL,
14
+ `created_by` text NOT NULL,
15
+ `expires_at` integer NOT NULL,
16
+ `last_used_at` integer,
17
+ `last_used_ip` text,
18
+ `revoked_at` integer,
19
+ `revoked_by` text,
20
+ FOREIGN KEY (`principal`) REFERENCES `vault_members`(`principal`) ON UPDATE no action ON DELETE restrict,
21
+ FOREIGN KEY (`identity_id`,`principal`,`generation`) REFERENCES `identities`(`id`,`principal`,`generation`) ON UPDATE no action ON DELETE restrict,
22
+ CONSTRAINT "credentials_kind_check" CHECK("__new_credentials"."kind" IN ('browser', 'cli', 'service', 'personal', 'handle')),
23
+ CONSTRAINT "credentials_principal_check" CHECK("__new_credentials"."principal" LIKE 'user:%' OR "__new_credentials"."principal" LIKE 'token:%'),
24
+ CONSTRAINT "credentials_kind_matches_principal" CHECK(("__new_credentials"."kind" = 'service') = ("__new_credentials"."principal" LIKE 'token:%')),
25
+ CONSTRAINT "credentials_token_hash_check" CHECK(octet_length("__new_credentials"."token_hash") = 32),
26
+ CONSTRAINT "credentials_auth_mac_check" CHECK(octet_length("__new_credentials"."auth_mac") = 32)
27
+ );
28
+ --> statement-breakpoint
29
+ INSERT INTO `__new_credentials`("id", "kind", "auth_mac", "token_hash", "token_hint", "generation", "principal", "identity_id", "scope", "label", "created_at", "created_by", "expires_at", "last_used_at", "last_used_ip", "revoked_at", "revoked_by") SELECT "id", "kind", "auth_mac", "token_hash", "token_hint", "generation", "principal", "identity_id", "scope", "label", "created_at", "created_by", "expires_at", "last_used_at", "last_used_ip", "revoked_at", "revoked_by" FROM `credentials`;--> statement-breakpoint
30
+ DROP TABLE `credentials`;--> statement-breakpoint
31
+ ALTER TABLE `__new_credentials` RENAME TO `credentials`;--> statement-breakpoint
32
+ PRAGMA foreign_keys=ON;--> statement-breakpoint
33
+ CREATE INDEX `credentials_principal_idx` ON `credentials` (`principal`,`generation`);--> statement-breakpoint
34
+ CREATE INDEX `credentials_live_idx` ON `credentials` (`principal`,`expires_at`) WHERE "credentials"."revoked_at" IS NULL;--> statement-breakpoint
35
+ CREATE INDEX `credentials_issued_by_idx` ON `credentials` (`principal`,`created_by`,`created_at`);--> statement-breakpoint
36
+ CREATE UNIQUE INDEX `credentials_token_hash_key` ON `credentials` (`token_hash`);