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

071_PeerLinkFence.ts

17 lines601 Bytes

1import * as Effect from "effect/Effect";
2import * as SqlClient from "effect/sql/SqlClient";
3​
4export default Effect.gen(function* () {
5 const sql = yield* SqlClient.SqlClient;
6 const columns = yield* sql<{ readonly name: string }>`
7 PRAGMA table_info(peer_environment_links)
8 `;
9​
10 // Whether the link's session was issued as a link, which the peer fences.
11 // Links stored before it are not, and must be made again.
12 if (!columns.some((column) => column.name === "fenced")) {
13 yield* sql`
14 ALTER TABLE peer_environment_links ADD COLUMN fenced INTEGER NOT NULL DEFAULT 0
15 `;
16 }
17});