Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

053_ProjectionUsageLimitResume.ts

32 lines994 Bytes

1import * as Effect from "effect/Effect";
2import * as SqlClient from "effect/unstable/sql/SqlClient";
3​
4export default Effect.gen(function* () {
5 const sql = yield* SqlClient.SqlClient;
6​
7 const sessionColumns = yield* sql<{ readonly name: string }>`
8 PRAGMA table_info(projection_thread_sessions)
9 `;
10 if (!sessionColumns.some((column) => column.name === "last_error_kind")) {
11 yield* sql`
12 ALTER TABLE projection_thread_sessions
13 ADD COLUMN last_error_kind TEXT
14 `;
15 }
16 if (!sessionColumns.some((column) => column.name === "last_error_resets_at")) {
17 yield* sql`
18 ALTER TABLE projection_thread_sessions
19 ADD COLUMN last_error_resets_at TEXT
20 `;
21 }
22​
23 const threadColumns = yield* sql<{ readonly name: string }>`
24 PRAGMA table_info(projection_threads)
25 `;
26 if (!threadColumns.some((column) => column.name === "usage_limit_resume_at")) {
27 yield* sql`
28 ALTER TABLE projection_threads
29 ADD COLUMN usage_limit_resume_at TEXT
30 `;
31 }
32});