1import * as Effect from "effect/Effect";
2import * as SqlClient from "effect/sql/SqlClient";
3
4// Client-declared surface (web/desktop/mobile) and app version, refreshed on
5// every WebSocket connect so the row tracks the client's current build instead
6// of freezing at session issuance. Nullable: old clients never report them.
7export default Effect.gen(function* () {
8 const sql = yield* SqlClient.SqlClient;
9 const columns = yield* sql<{ readonly name: string }>`
10 PRAGMA table_info(auth_sessions)
11 `;
12
13 if (!columns.some((column) => column.name === "client_surface")) {
14 yield* sql`
15 ALTER TABLE auth_sessions
16 ADD COLUMN client_surface TEXT
17 `;
18 }
19
20 if (!columns.some((column) => column.name === "client_app_version")) {
21 yield* sql`
22 ALTER TABLE auth_sessions
23 ADD COLUMN client_app_version TEXT
24 `;
25 }
26});