Open History to see the last commit
1/**
2 * The column is nullable on purpose — backfilling it during the migration would
3 * require knowing which configured instance "owned" each historical session,
4 * and that mapping is ambiguous when the user later configures multiple
5 * instances of the same driver.
6 */
7import * as SqlClient from "effect/sql/SqlClient";
8import * as Effect from "effect/Effect";
9
10export default Effect.gen(function* () {
11 const sql = yield* SqlClient.SqlClient;
12
13 const columns = yield* sql<{ readonly name: string }>`
14 PRAGMA table_info(provider_session_runtime)
15 `;
16 if (!columns.some((column) => column.name === "provider_instance_id")) {
17 yield* sql`
18 ALTER TABLE provider_session_runtime
19 ADD COLUMN provider_instance_id TEXT
20 `;
21 }
22
23 yield* sql`
24 CREATE INDEX IF NOT EXISTS idx_provider_session_runtime_instance
25 ON provider_session_runtime(provider_instance_id)
26 `;
27});