@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,65 @@
|
|
|
1
|
+
ALTER TABLE "t_sessions" ADD COLUMN "f_archived_at" bigint;
|
|
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" s SET "f_title" = sub.title, "f_title_seq" = sub.seq
|
|
8
|
+
FROM (
|
|
9
|
+
SELECT DISTINCT ON (b.f_session_id) b.f_session_id,
|
|
10
|
+
COALESCE(e.f_data::jsonb -> 'data' ->> 'title', e.f_data::jsonb ->> 'title') AS title,
|
|
11
|
+
b.f_sequence AS seq
|
|
12
|
+
FROM t_session_events b JOIN t_events e ON e.f_event_id = b.f_event_id
|
|
13
|
+
WHERE e.f_type = 'session/title'
|
|
14
|
+
ORDER BY b.f_session_id, b.f_sequence DESC
|
|
15
|
+
) sub
|
|
16
|
+
WHERE s.f_session_id = sub.f_session_id;
|
|
17
|
+
--> statement-breakpoint
|
|
18
|
+
CREATE TABLE "t_session_projcache_row" (
|
|
19
|
+
"f_id" serial PRIMARY KEY,
|
|
20
|
+
"f_session_id" text NOT NULL,
|
|
21
|
+
"f_key" text NOT NULL,
|
|
22
|
+
"f_ver" integer NOT NULL,
|
|
23
|
+
"f_seq" integer NOT NULL,
|
|
24
|
+
"f_val" text NOT NULL,
|
|
25
|
+
CONSTRAINT "uq_session_projcache_row_session_key" UNIQUE("f_session_id", "f_key")
|
|
26
|
+
);
|
|
27
|
+
--> statement-breakpoint
|
|
28
|
+
CREATE TABLE "t_storage_units" (
|
|
29
|
+
"f_name" text PRIMARY KEY,
|
|
30
|
+
"f_version" integer NOT NULL
|
|
31
|
+
);
|
|
32
|
+
--> statement-breakpoint
|
|
33
|
+
CREATE TABLE "t_workspace_state" (
|
|
34
|
+
"f_singleton" integer PRIMARY KEY,
|
|
35
|
+
"f_initialized" integer NOT NULL,
|
|
36
|
+
"f_pending_operation" text,
|
|
37
|
+
"f_pending_workspace_id" text,
|
|
38
|
+
CONSTRAINT "ck_workspace_state_singleton" CHECK (f_singleton = 1)
|
|
39
|
+
);
|
|
40
|
+
--> statement-breakpoint
|
|
41
|
+
CREATE TABLE "t_workspaces" (
|
|
42
|
+
"f_id" serial PRIMARY KEY,
|
|
43
|
+
"f_workspace_id" text NOT NULL UNIQUE,
|
|
44
|
+
"f_path" text NOT NULL,
|
|
45
|
+
"f_title" text NOT NULL,
|
|
46
|
+
"f_created_at" text NOT NULL,
|
|
47
|
+
"f_updated_at" text NOT NULL,
|
|
48
|
+
"f_position" integer DEFAULT -1 NOT NULL
|
|
49
|
+
);
|
|
50
|
+
--> statement-breakpoint
|
|
51
|
+
CREATE TABLE "t_workspace_sessions" (
|
|
52
|
+
"f_id" serial PRIMARY KEY,
|
|
53
|
+
"f_workspace_id" text NOT NULL,
|
|
54
|
+
"f_session_id" text NOT NULL,
|
|
55
|
+
"f_position" integer NOT NULL,
|
|
56
|
+
CONSTRAINT "uq_workspace_sessions_workspace_session" UNIQUE("f_workspace_id", "f_session_id")
|
|
57
|
+
);
|
|
58
|
+
--> statement-breakpoint
|
|
59
|
+
CREATE INDEX "idx_session_projcache_row_key" ON "t_session_projcache_row" ("f_key");
|
|
60
|
+
--> statement-breakpoint
|
|
61
|
+
CREATE INDEX "idx_workspace_sessions_session_id" ON "t_workspace_sessions" ("f_session_id");
|
|
62
|
+
--> statement-breakpoint
|
|
63
|
+
ALTER TABLE "t_session_projcache_row" ADD 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;
|
|
64
|
+
--> statement-breakpoint
|
|
65
|
+
ALTER TABLE "t_workspace_sessions" ADD 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;
|