@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 39 lines 1.35 KB
Raw
1 import { assert, it } from "@effect/vitest";
2 import * as Effect from "effect/Effect";
3 import * as Layer from "effect/Layer";
4 import * as SqlClient from "effect/sql/SqlClient";
5
6 import { runMigrations } from "../Migrations.ts";
7 import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
8
9 const layer = it.layer(Layer.mergeAll(NodeSqliteClient.layer({ filename: ":memory:" })));
10
11 layer("051_ProjectionThreadMessageContext", (it) => {
12 it.effect("accepts context added by an earlier development migration", () =>
13 Effect.gen(function* () {
14 const sql = yield* SqlClient.SqlClient;
15
16 yield* runMigrations({ toMigrationInclusive: 50 });
17 yield* sql`
18 ALTER TABLE projection_thread_messages
19 ADD COLUMN context_json TEXT
20 `;
21
22 yield* runMigrations({ toMigrationInclusive: 51 });
23
24 const columns = yield* sql<{ readonly name: string; readonly notnull: number }>`
25 PRAGMA table_info(projection_thread_messages)
26 `;
27 const context = columns.find((column) => column.name === "context_json");
28 const migrations = yield* sql<{ readonly migration_id: number }>`
29 SELECT migration_id
30 FROM effect_sql_migrations
31 WHERE migration_id = 51
32 `;
33
34 assert.equal(context?.name, "context_json");
35 assert.equal(context?.notnull, 0);
36 assert.equal(migrations.length, 1);
37 }),
38 );
39 });