@catalyst-cloud/schema 0.1.0 → 0.1.2
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/package.json +2 -1
- package/src/index.ts +4 -4
- package/src/migrate.ts +1 -1
- package/src/migrations.generated.ts +9 -0
- package/src/mirror.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@catalyst-cloud/schema",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Typed Drizzle schema = single source of truth for the per-tenant Mirror DO SQLite store (CTC-13 / ADR-0002). Shared by the mirror Worker, the host-sync replica, and the browser OPFS replica.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"test": "vitest run",
|
|
24
24
|
"test:coverage": "vitest run --coverage",
|
|
25
25
|
"generate": "drizzle-kit generate",
|
|
26
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
27
|
"build:bundle": "bun scripts/build-bundle.ts && prettier --write src/migrations.generated.ts"
|
|
27
28
|
},
|
|
28
29
|
"dependencies": {
|
package/src/index.ts
CHANGED
|
@@ -28,19 +28,19 @@ import {
|
|
|
28
28
|
processed_events,
|
|
29
29
|
change_log,
|
|
30
30
|
sync_cursors,
|
|
31
|
-
} from "./mirror";
|
|
31
|
+
} from "./mirror.js";
|
|
32
32
|
|
|
33
|
-
export * from "./mirror";
|
|
33
|
+
export * from "./mirror.js";
|
|
34
34
|
|
|
35
35
|
// The committed cross-surface migration bundle + the shared runner (CTC-41). Re-exported here so
|
|
36
36
|
// every consumer imports from the one package entrypoint: `applyMigrations(adapter, MIRROR_MIGRATIONS)`.
|
|
37
|
-
export { MIRROR_MIGRATIONS } from "./migrations.generated";
|
|
37
|
+
export { MIRROR_MIGRATIONS } from "./migrations.generated.js";
|
|
38
38
|
export {
|
|
39
39
|
applyMigrations,
|
|
40
40
|
type MigrationDb,
|
|
41
41
|
type MigrationBundle,
|
|
42
42
|
type MigrationJournalEntry,
|
|
43
|
-
} from "./migrate";
|
|
43
|
+
} from "./migrate.js";
|
|
44
44
|
|
|
45
45
|
/** Every table in the Mirror DO store — pass as `drizzle(storage, { schema: mirrorSchema })`. */
|
|
46
46
|
export const mirrorSchema = {
|
package/src/migrate.ts
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
// runner keys on tags, so native-hash rows would be unrecognized and the baseline would re-run
|
|
24
24
|
// (safe only while the baseline stays IF NOT EXISTS). This runner owns the ledger end to end.
|
|
25
25
|
|
|
26
|
-
import { MIRROR_MIGRATIONS } from "./migrations.generated";
|
|
26
|
+
import { MIRROR_MIGRATIONS } from "./migrations.generated.js";
|
|
27
27
|
|
|
28
28
|
/** The minimal native SQLite surface the runner needs — one exec + one row-returning query. */
|
|
29
29
|
export interface MigrationDb {
|
|
@@ -67,6 +67,13 @@ export const MIRROR_MIGRATIONS = {
|
|
|
67
67
|
tag: "0007_rapid_logan",
|
|
68
68
|
breakpoints: true,
|
|
69
69
|
},
|
|
70
|
+
{
|
|
71
|
+
idx: 8,
|
|
72
|
+
version: "6",
|
|
73
|
+
when: 1782843988558,
|
|
74
|
+
tag: "0008_optimal_rattler",
|
|
75
|
+
breakpoints: true,
|
|
76
|
+
},
|
|
70
77
|
],
|
|
71
78
|
},
|
|
72
79
|
migrations: {
|
|
@@ -86,5 +93,7 @@ export const MIRROR_MIGRATIONS = {
|
|
|
86
93
|
"CREATE TABLE `initiatives` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`name` text,\n\t`description` text,\n\t`status` text,\n\t`target_date` text,\n\t`owner_id` text,\n\t`updated_at` integer\n);\n--> statement-breakpoint\nCREATE TABLE `project_initiatives` (\n\t`project_id` text NOT NULL,\n\t`initiative_id` text NOT NULL,\n\tPRIMARY KEY(`project_id`, `initiative_id`)\n);\n--> statement-breakpoint\nALTER TABLE `cycles` ADD `name` text;--> statement-breakpoint\nALTER TABLE `cycles` ADD `progress` real;--> statement-breakpoint\nALTER TABLE `cycles` ADD `completed_scope` real;--> statement-breakpoint\nALTER TABLE `cycles` ADD `scope` real;--> statement-breakpoint\nALTER TABLE `cycles` ADD `completed_issue_count` integer;--> statement-breakpoint\nALTER TABLE `cycles` ADD `issue_count` integer;--> statement-breakpoint\nALTER TABLE `projects` ADD `description` text;--> statement-breakpoint\nALTER TABLE `projects` ADD `lead_id` text;--> statement-breakpoint\nALTER TABLE `projects` ADD `target_date` text;--> statement-breakpoint\nALTER TABLE `projects` ADD `start_date` text;--> statement-breakpoint\nALTER TABLE `projects` ADD `progress` real;--> statement-breakpoint\nALTER TABLE `projects` ADD `health` text;--> statement-breakpoint\nALTER TABLE `projects` ADD `icon` text;--> statement-breakpoint\nALTER TABLE `projects` ADD `color` text;",
|
|
87
94
|
"0007_rapid_logan":
|
|
88
95
|
"CREATE TABLE `issue_history` (\n\t`id` text PRIMARY KEY NOT NULL,\n\t`issue_id` text NOT NULL,\n\t`actor_id` text,\n\t`created_at` integer,\n\t`updated_at` integer,\n\t`from_state` text,\n\t`to_state` text,\n\t`from_assignee_id` text,\n\t`to_assignee_id` text,\n\t`from_priority` integer,\n\t`to_priority` integer,\n\t`from_estimate` real,\n\t`to_estimate` real,\n\t`from_title` text,\n\t`to_title` text,\n\t`from_cycle_id` text,\n\t`to_cycle_id` text,\n\t`from_project_id` text,\n\t`to_project_id` text,\n\t`from_parent_id` text,\n\t`to_parent_id` text,\n\t`from_team_id` text,\n\t`to_team_id` text,\n\t`from_due_date` text,\n\t`to_due_date` text,\n\t`added_label_ids` text,\n\t`removed_label_ids` text,\n\t`updated_description` integer,\n\t`archived` integer,\n\t`auto_archived` integer,\n\t`auto_closed` integer,\n\t`trashed` integer,\n\t`raw` text\n);\n--> statement-breakpoint\nCREATE INDEX `idx_issue_history_issue_created` ON `issue_history` (`issue_id`,`created_at`);",
|
|
96
|
+
"0008_optimal_rattler":
|
|
97
|
+
"ALTER TABLE `issues` ADD `state_id` text;--> statement-breakpoint\nALTER TABLE `issues` ADD `team_key` text;--> statement-breakpoint\nALTER TABLE `issues` ADD `team_name` text;",
|
|
89
98
|
},
|
|
90
99
|
} as const;
|
package/src/mirror.ts
CHANGED
|
@@ -28,6 +28,9 @@ export const issues = sqliteTable(
|
|
|
28
28
|
title: text("title"),
|
|
29
29
|
description: text("description"),
|
|
30
30
|
state: text("state"),
|
|
31
|
+
// CTC-148: the workflow state id behind the `state` NAME — lets a consumer key on state without
|
|
32
|
+
// string-matching the renameable name.
|
|
33
|
+
state_id: text("state_id"),
|
|
31
34
|
assignee: text("assignee"),
|
|
32
35
|
// CTC-USERS: the assignee's user id (FK → users.id), so the row JOINs to a name + avatar. The
|
|
33
36
|
// legacy `assignee` name string is KEPT for back-compat (the SSE list row still carries it).
|
|
@@ -37,6 +40,10 @@ export const issues = sqliteTable(
|
|
|
37
40
|
project_id: text("project_id"),
|
|
38
41
|
cycle_id: text("cycle_id"),
|
|
39
42
|
team_id: text("team_id"),
|
|
43
|
+
// CTC-148: denormalized team key + name (off the issue's `team` ref) so a row labels its team
|
|
44
|
+
// ("ENG / Engineering") without a teams lookup. team_id is KEPT.
|
|
45
|
+
team_key: text("team_key"),
|
|
46
|
+
team_name: text("team_name"),
|
|
40
47
|
delegate_id: text("delegate_id"),
|
|
41
48
|
delegate_name: text("delegate_name"),
|
|
42
49
|
bot_actor_name: text("bot_actor_name"),
|