1import * as SqlClient from "effect/sql/SqlClient";
2import * as Effect from "effect/Effect";
3
4export default Effect.gen(function* () {
5 const sql = yield* SqlClient.SqlClient;
6
7 const columns = yield* sql<{ readonly name: string }>`
8 PRAGMA table_info(projection_thread_sessions)
9 `;
10 if (!columns.some((column) => column.name === "provider_instance_id")) {
11 yield* sql`
12 ALTER TABLE projection_thread_sessions
13 ADD COLUMN provider_instance_id TEXT
14 `;
15 }
16
17 yield* sql`
18 CREATE INDEX IF NOT EXISTS idx_projection_thread_sessions_instance
19 ON projection_thread_sessions(provider_instance_id)
20 `;
21});