The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { assert, it } from "@effect/vitest"; |
| 2 | import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient"; |
| 3 | import * as Effect from "effect/Effect"; |
| 4 | import * as SqlClient from "effect/sql/SqlClient"; |
| 5 | |
| 6 | import { runMigrations } from "../Migrations.ts"; |
| 7 | |
| 8 | const layer = it.layer(NodeSqliteClient.layer({ filename: ":memory:" })); |
| 9 | |
| 10 | layer("063_DropUnusedV1Projections", (it) => { |
| 11 | it.effect("drops V1 projections nothing reads and keeps the transcript import sources", () => |
| 12 | Effect.gen(function* () { |
| 13 | const sql = yield* SqlClient.SqlClient; |
| 14 | yield* runMigrations({ toMigrationInclusive: 62 }); |
| 15 | yield* sql` |
| 16 | INSERT INTO projection_thread_messages |
| 17 | (message_id, thread_id, role, text, is_streaming, created_at, updated_at) |
| 18 | VALUES ('message-1', 'thread-1', 'user', 'hello', 0, '2026-01-01', '2026-01-01') |
| 19 | `; |
| 20 | |
| 21 | yield* runMigrations({ toMigrationInclusive: 63 }); |
| 22 | |
| 23 | const rows = yield* sql<{ readonly name: string }>` |
| 24 | SELECT name FROM sqlite_master WHERE type = 'table' |
| 25 | `; |
| 26 | const tables = new Set(rows.map((row) => row.name)); |
| 27 | for (const dropped of [ |
| 28 | "projection_thread_activities", |
| 29 | "projection_turns", |
| 30 | "projection_thread_proposed_plans", |
| 31 | "projection_pending_approvals", |
| 32 | "projection_state", |
| 33 | "checkpoint_diff_blobs", |
| 34 | ]) { |
| 35 | assert.isFalse(tables.has(dropped), dropped); |
| 36 | } |
| 37 | for (const kept of [ |
| 38 | "projection_threads", |
| 39 | "projection_thread_messages", |
| 40 | "projection_thread_pull_requests", |
| 41 | ]) { |
| 42 | assert.isTrue(tables.has(kept), kept); |
| 43 | } |
| 44 | assert.deepEqual(yield* sql`SELECT message_id FROM projection_thread_messages`, [ |
| 45 | { message_id: "message-1" }, |
| 46 | ]); |
| 47 | }), |
| 48 | ); |
| 49 | }); |