@morlay/session-rdb 0.0.16 → 0.0.18
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.
- package/README.md +44 -10
- package/dist/artifact.d.mts +9 -2
- package/dist/artifact.mjs +3 -3
- package/dist/{import-BPEHfHNk.mjs → import-DZIAjOUr.mjs} +2 -1
- package/dist/import.d.mts +1 -1
- package/dist/import.mjs +1 -1
- package/dist/{index-CgAqCQAb.d.mts → index-BEKoV1Uy.d.mts} +11 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +509 -6
- package/dist/{log-BIuXv09P.mjs → log-DO69NQnn.mjs} +16 -1
- package/dist/schema-Bo6Hy5gW.d.mts +3476 -0
- package/dist/{sqlite-IH5I48aL.mjs → sqlite-BIPdMNQb.mjs} +504 -6
- package/dist/storage.d.mts +10 -2
- package/dist/storage.mjs +2 -2
- package/dist/testing.d.mts +1 -1
- package/dist/testing.mjs +1 -1
- package/drizzle/postgres/20260910120001_v3_storage_tables/migration.sql +65 -0
- package/drizzle/postgres/20260910120001_v3_storage_tables/snapshot.json +1236 -0
- package/drizzle/postgres/20260910130001_v3_session_title_backfill/migration.sql +10 -0
- package/drizzle/postgres/20260910130001_v3_session_title_backfill/snapshot.json +1236 -0
- package/drizzle/sqlite/20260910120000_v3_storage_tables/migration.sql +66 -0
- package/drizzle/sqlite/20260910120000_v3_storage_tables/snapshot.json +958 -0
- package/drizzle/sqlite/20260910130000_v3_session_title_backfill/migration.sql +13 -0
- package/drizzle/sqlite/20260910130000_v3_session_title_backfill/snapshot.json +958 -0
- package/package.json +20 -18
- package/src/backend.ts +7 -0
- package/src/branch.ts +2 -0
- package/src/drizzle/postgres-v3.ts +5 -0
- package/src/drizzle/sqlite-v3.ts +5 -0
- package/src/entities/v3/index.ts +20 -0
- package/src/entities/v3/session-projcache-rows.ts +27 -0
- package/src/entities/v3/sessions.ts +6 -0
- package/src/entities/v3/storage-units.ts +10 -0
- package/src/entities/v3/workspace-sessions.ts +24 -0
- package/src/entities/v3/workspace-state.ts +18 -0
- package/src/entities/v3/workspaces.ts +19 -0
- package/src/import-storages.ts +173 -0
- package/src/index.ts +53 -0
- package/src/log.ts +19 -0
- package/src/postgres.ts +70 -2
- package/src/schema.ts +16 -2
- package/src/sqlite.ts +87 -4
- package/src/storage-takeover/index.ts +60 -0
- package/src/storage-takeover/projection-cache.ts +445 -0
- package/src/storage-takeover/repository.ts +420 -0
- package/src/storage-takeover/storage-backend.ts +177 -0
- package/src/storage-takeover/types.ts +82 -0
- package/dist/schema-COK7-wRV.d.mts +0 -104
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
ALTER TABLE `t_sessions` ADD COLUMN `f_archived_at` integer;
|
|
2
|
+
--> statement-breakpoint
|
|
3
|
+
ALTER TABLE `t_sessions` ADD COLUMN `f_title` text;
|
|
4
|
+
--> statement-breakpoint
|
|
5
|
+
ALTER TABLE `t_sessions` ADD COLUMN `f_title_seq` integer;
|
|
6
|
+
--> statement-breakpoint
|
|
7
|
+
UPDATE `t_sessions` SET
|
|
8
|
+
`f_title` = (
|
|
9
|
+
SELECT COALESCE(json_extract(e.`f_data`, '$.data.title'), json_extract(e.`f_data`, '$.title'))
|
|
10
|
+
FROM `t_session_events` b JOIN `t_events` e ON e.`f_event_id` = b.`f_event_id`
|
|
11
|
+
WHERE b.`f_session_id` = `t_sessions`.`f_session_id` AND e.`f_type` = 'session/title'
|
|
12
|
+
ORDER BY b.`f_sequence` DESC LIMIT 1
|
|
13
|
+
),
|
|
14
|
+
`f_title_seq` = (
|
|
15
|
+
SELECT b.`f_sequence`
|
|
16
|
+
FROM `t_session_events` b JOIN `t_events` e ON e.`f_event_id` = b.`f_event_id`
|
|
17
|
+
WHERE b.`f_session_id` = `t_sessions`.`f_session_id` AND e.`f_type` = 'session/title'
|
|
18
|
+
ORDER BY b.`f_sequence` DESC LIMIT 1
|
|
19
|
+
);
|
|
20
|
+
--> statement-breakpoint
|
|
21
|
+
CREATE TABLE `t_session_projcache_row` (
|
|
22
|
+
`f_id` integer PRIMARY KEY AUTOINCREMENT,
|
|
23
|
+
`f_session_id` text NOT NULL,
|
|
24
|
+
`f_key` text NOT NULL,
|
|
25
|
+
`f_ver` integer NOT NULL,
|
|
26
|
+
`f_seq` integer NOT NULL,
|
|
27
|
+
`f_val` text NOT NULL,
|
|
28
|
+
CONSTRAINT `uq_session_projcache_row_session_key` UNIQUE(`f_session_id`, `f_key`),
|
|
29
|
+
CONSTRAINT `fk_t_session_projcache_row_f_session_id_t_sessions_f_session_id_fk` FOREIGN KEY (`f_session_id`) REFERENCES `t_sessions`(`f_session_id`) ON DELETE CASCADE
|
|
30
|
+
);
|
|
31
|
+
--> statement-breakpoint
|
|
32
|
+
CREATE TABLE `t_storage_units` (
|
|
33
|
+
`f_name` text PRIMARY KEY,
|
|
34
|
+
`f_version` integer NOT NULL
|
|
35
|
+
);
|
|
36
|
+
--> statement-breakpoint
|
|
37
|
+
CREATE TABLE `t_workspace_state` (
|
|
38
|
+
`f_singleton` integer PRIMARY KEY,
|
|
39
|
+
`f_initialized` integer NOT NULL,
|
|
40
|
+
`f_pending_operation` text,
|
|
41
|
+
`f_pending_workspace_id` text,
|
|
42
|
+
CONSTRAINT `ck_workspace_state_singleton` CHECK(f_singleton = 1)
|
|
43
|
+
);
|
|
44
|
+
--> statement-breakpoint
|
|
45
|
+
CREATE TABLE `t_workspaces` (
|
|
46
|
+
`f_id` integer PRIMARY KEY AUTOINCREMENT,
|
|
47
|
+
`f_workspace_id` text NOT NULL UNIQUE,
|
|
48
|
+
`f_path` text NOT NULL,
|
|
49
|
+
`f_title` text NOT NULL,
|
|
50
|
+
`f_created_at` text NOT NULL,
|
|
51
|
+
`f_updated_at` text NOT NULL,
|
|
52
|
+
`f_position` integer DEFAULT -1 NOT NULL
|
|
53
|
+
);
|
|
54
|
+
--> statement-breakpoint
|
|
55
|
+
CREATE TABLE `t_workspace_sessions` (
|
|
56
|
+
`f_id` integer PRIMARY KEY AUTOINCREMENT,
|
|
57
|
+
`f_workspace_id` text NOT NULL,
|
|
58
|
+
`f_session_id` text NOT NULL,
|
|
59
|
+
`f_position` integer NOT NULL,
|
|
60
|
+
CONSTRAINT `uq_workspace_sessions_workspace_session` UNIQUE(`f_workspace_id`, `f_session_id`),
|
|
61
|
+
CONSTRAINT `fk_t_workspace_sessions_f_workspace_id_t_workspaces_f_workspace_id_fk` FOREIGN KEY (`f_workspace_id`) REFERENCES `t_workspaces`(`f_workspace_id`) ON DELETE CASCADE
|
|
62
|
+
);
|
|
63
|
+
--> statement-breakpoint
|
|
64
|
+
CREATE INDEX `idx_session_projcache_row_key` ON `t_session_projcache_row` (`f_key`);
|
|
65
|
+
--> statement-breakpoint
|
|
66
|
+
CREATE INDEX `idx_workspace_sessions_session_id` ON `t_workspace_sessions` (`f_session_id`);
|