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
7 // One row per file a reader has cleared on a host that keeps no record of its own. `revision`
8 // is what the file was when it was cleared, so a push that changes it is reported as changed
9 // rather than silently left ticked, and it is nullable for the reason `PullRequestFileViewedMark`
10 // gives. Unticking deletes the row: absent is the resting state, and a table of "not viewed"
11 // rows would grow with every diff anybody scrolled past.
12 yield* sql`
13 CREATE TABLE IF NOT EXISTS pull_request_files_viewed (
14 provider TEXT NOT NULL,
15 host TEXT NOT NULL,
16 repository TEXT NOT NULL,
17 number INTEGER NOT NULL,
18 viewer TEXT NOT NULL,
19 path TEXT NOT NULL,
20 revision TEXT,
21 viewed_at TEXT NOT NULL,
22 PRIMARY KEY (provider, host, repository, number, viewer, path)
23 ) WITHOUT ROWID
24 `;
25});