prism-pr 1.0.0-alpha.57 → 1.0.0-alpha.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,10 @@
1
- import { drizzle } from 'drizzle-orm/better-sqlite3';
1
+ import { drizzle } from 'drizzle-orm/node-sqlite';
2
2
  import * as schema from './schema.js';
3
3
  import type { Logger } from '../utils/logger.js';
4
4
  export type DrizzleDb = ReturnType<typeof drizzle<typeof schema>>;
5
5
  export declare function getDatabase(logger: Logger, dbPath?: string): DrizzleDb | null;
6
- /** Reset the singleton only used in tests via vi.resetModules() */
6
+ /** Close the database connection and reset the singleton. */
7
+ export declare function closeDatabase(): void;
8
+ /** @deprecated Use closeDatabase() instead */
7
9
  export declare function _resetDbInstance(): void;
8
10
  //# sourceMappingURL=database.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/persistence/database.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAErD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC;AAuBlE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA6B7E;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
1
+ {"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/persistence/database.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAClD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,OAAO,CAAC,OAAO,MAAM,CAAC,CAAC,CAAC;AAiFlE,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CA8B7E;AAED,6DAA6D;AAC7D,wBAAgB,aAAa,IAAI,IAAI,CAIpC;AAED,8CAA8C;AAC9C,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC"}
@@ -1,12 +1,12 @@
1
1
  import path from 'node:path';
2
2
  import fs from 'node:fs';
3
3
  import { fileURLToPath } from 'node:url';
4
- import Database from 'better-sqlite3';
5
- import { drizzle } from 'drizzle-orm/better-sqlite3';
6
- import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
4
+ import { DatabaseSync } from 'node:sqlite';
5
+ import { drizzle } from 'drizzle-orm/node-sqlite';
7
6
  import * as schema from './schema.js';
8
7
  import { ensureConfigDir, getDbPath } from '../utils/paths.js';
9
8
  let dbInstance = null;
9
+ let rawHandle = null;
10
10
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
11
11
  /**
12
12
  * Resolve the migrations folder. Prefers dist/ (postbuild copy), falls back to src/.
@@ -24,6 +24,49 @@ function resolveMigrationsFolder() {
24
24
  return srcMigrations;
25
25
  throw new Error(`Migrations not found in ${distMigrations} or ${srcMigrations}`);
26
26
  }
27
+ /**
28
+ * Simple migration runner — reads _journal.json and executes SQL files in order.
29
+ * Tracks applied migrations in a __drizzle_migrations table.
30
+ */
31
+ function runMigrations(sqlite, folder) {
32
+ sqlite.exec(`CREATE TABLE IF NOT EXISTS __drizzle_migrations (
33
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
34
+ tag TEXT NOT NULL UNIQUE,
35
+ created_at INTEGER NOT NULL DEFAULT (unixepoch())
36
+ )`);
37
+ const journalPath = path.join(folder, 'meta', '_journal.json');
38
+ const journal = JSON.parse(fs.readFileSync(journalPath, 'utf-8'));
39
+ const applied = new Set(sqlite.prepare('SELECT tag FROM __drizzle_migrations').all()
40
+ .map(r => r.tag));
41
+ for (const entry of journal.entries) {
42
+ if (applied.has(entry.tag))
43
+ continue;
44
+ // Support both folder format (tag/migration.sql) and flat format (tag.sql)
45
+ const folderSql = path.join(folder, entry.tag, 'migration.sql');
46
+ const flatSql = path.join(folder, `${entry.tag}.sql`);
47
+ // Also support timestamped folder format
48
+ const timestampedDirs = fs.readdirSync(folder).filter(d => d.endsWith(`_${entry.tag.replace(/^\d+_/, '')}`));
49
+ const timestampedSql = timestampedDirs.length > 0
50
+ ? path.join(folder, timestampedDirs[0], 'migration.sql')
51
+ : '';
52
+ let sqlPath;
53
+ if (fs.existsSync(folderSql)) {
54
+ sqlPath = folderSql;
55
+ }
56
+ else if (fs.existsSync(flatSql)) {
57
+ sqlPath = flatSql;
58
+ }
59
+ else if (timestampedSql && fs.existsSync(timestampedSql)) {
60
+ sqlPath = timestampedSql;
61
+ }
62
+ else {
63
+ throw new Error(`Migration SQL not found for tag "${entry.tag}" in ${folder}`);
64
+ }
65
+ const sql = fs.readFileSync(sqlPath, 'utf-8');
66
+ sqlite.exec(sql);
67
+ sqlite.prepare('INSERT INTO __drizzle_migrations (tag) VALUES (?)').run(entry.tag);
68
+ }
69
+ }
27
70
  export function getDatabase(logger, dbPath) {
28
71
  if (dbInstance !== null)
29
72
  return dbInstance;
@@ -36,12 +79,13 @@ export function getDatabase(logger, dbPath) {
36
79
  else {
37
80
  ensureConfigDir();
38
81
  }
39
- const sqlite = new Database(resolvedPath);
40
- sqlite.pragma('journal_mode = WAL');
41
- sqlite.pragma('foreign_keys = ON');
42
- const db = drizzle(sqlite, { schema });
82
+ const sqlite = new DatabaseSync(resolvedPath);
83
+ sqlite.exec('PRAGMA journal_mode = WAL');
84
+ sqlite.exec('PRAGMA foreign_keys = ON');
85
+ const db = drizzle({ client: sqlite, schema });
43
86
  const migrationsFolder = resolveMigrationsFolder();
44
- migrate(db, { migrationsFolder });
87
+ runMigrations(sqlite, migrationsFolder);
88
+ rawHandle = sqlite;
45
89
  dbInstance = db;
46
90
  return db;
47
91
  }
@@ -51,7 +95,13 @@ export function getDatabase(logger, dbPath) {
51
95
  return null;
52
96
  }
53
97
  }
54
- /** Reset the singleton only used in tests via vi.resetModules() */
98
+ /** Close the database connection and reset the singleton. */
99
+ export function closeDatabase() {
100
+ rawHandle?.close();
101
+ rawHandle = null;
102
+ dbInstance = null;
103
+ }
104
+ /** @deprecated Use closeDatabase() instead */
55
105
  export function _resetDbInstance() {
56
106
  dbInstance = null;
57
107
  }
@@ -1 +1 @@
1
- {"version":3,"file":"database.js","sourceRoot":"","sources":["../../src/persistence/database.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAK/D,IAAI,UAAU,GAAqB,IAAI,CAAC;AAExC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D;;;GAGG;AACH,SAAS,uBAAuB;IAC9B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC;IACnE,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,cAAc,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"}
@@ -0,0 +1,66 @@
1
+ CREATE TABLE `agent_results` (
2
+ `id` text PRIMARY KEY NOT NULL,
3
+ `session_id` text NOT NULL,
4
+ `agent_id` text NOT NULL,
5
+ `status` text NOT NULL,
6
+ `error_message` text,
7
+ `input_tokens` integer DEFAULT 0 NOT NULL,
8
+ `output_tokens` integer DEFAULT 0 NOT NULL,
9
+ `findings_count` integer DEFAULT 0 NOT NULL,
10
+ `created_at` text NOT NULL,
11
+ FOREIGN KEY (`session_id`) REFERENCES `review_sessions`(`id`) ON UPDATE no action ON DELETE no action
12
+ );
13
+ --> statement-breakpoint
14
+ CREATE TABLE `project_profiles` (
15
+ `id` text PRIMARY KEY NOT NULL,
16
+ `workspace` text NOT NULL,
17
+ `repo` text NOT NULL,
18
+ `default_model` text,
19
+ `agent_ids` text,
20
+ `conventions` text,
21
+ `created_at` text NOT NULL,
22
+ `updated_at` text NOT NULL
23
+ );
24
+ --> statement-breakpoint
25
+ CREATE UNIQUE INDEX `idx_profiles_workspace_repo` ON `project_profiles` (`workspace`,`repo`);--> statement-breakpoint
26
+ CREATE TABLE `review_findings` (
27
+ `id` text PRIMARY KEY NOT NULL,
28
+ `session_id` text NOT NULL,
29
+ `file_path` text NOT NULL,
30
+ `line_number` integer NOT NULL,
31
+ `severity` text NOT NULL,
32
+ `category` text NOT NULL,
33
+ `title` text NOT NULL,
34
+ `problem` text NOT NULL,
35
+ `rationale` text NOT NULL,
36
+ `suggestion` text NOT NULL,
37
+ `agent_id` text NOT NULL,
38
+ `dedup_hash` text NOT NULL,
39
+ `status` text DEFAULT 'pending' NOT NULL,
40
+ `skip_reason` text,
41
+ `bitbucket_comment_id` integer,
42
+ `created_at` text NOT NULL,
43
+ FOREIGN KEY (`session_id`) REFERENCES `review_sessions`(`id`) ON UPDATE no action ON DELETE no action
44
+ );
45
+ --> statement-breakpoint
46
+ CREATE INDEX `idx_findings_session` ON `review_findings` (`session_id`);--> statement-breakpoint
47
+ CREATE INDEX `idx_findings_hash` ON `review_findings` (`dedup_hash`);--> statement-breakpoint
48
+ CREATE TABLE `review_sessions` (
49
+ `id` text PRIMARY KEY NOT NULL,
50
+ `workspace` text NOT NULL,
51
+ `repo` text NOT NULL,
52
+ `pr_id` integer NOT NULL,
53
+ `pr_title` text,
54
+ `pr_url` text,
55
+ `status` text DEFAULT 'pending' NOT NULL,
56
+ `agent_ids` text NOT NULL,
57
+ `model` text NOT NULL,
58
+ `findings_count` integer DEFAULT 0 NOT NULL,
59
+ `published_count` integer DEFAULT 0 NOT NULL,
60
+ `input_tokens` integer,
61
+ `output_tokens` integer,
62
+ `cost_usd` real,
63
+ `engram_saved` integer DEFAULT 0 NOT NULL,
64
+ `created_at` text NOT NULL,
65
+ `completed_at` text
66
+ );
@@ -0,0 +1,468 @@
1
+ {
2
+ "version": "6",
3
+ "dialect": "sqlite",
4
+ "id": "aa22db4e-eceb-4061-85c4-0759a189a860",
5
+ "prevId": "00000000-0000-0000-0000-000000000000",
6
+ "tables": {
7
+ "agent_results": {
8
+ "name": "agent_results",
9
+ "columns": {
10
+ "id": {
11
+ "name": "id",
12
+ "type": "text",
13
+ "primaryKey": true,
14
+ "notNull": true,
15
+ "autoincrement": false
16
+ },
17
+ "session_id": {
18
+ "name": "session_id",
19
+ "type": "text",
20
+ "primaryKey": false,
21
+ "notNull": true,
22
+ "autoincrement": false
23
+ },
24
+ "agent_id": {
25
+ "name": "agent_id",
26
+ "type": "text",
27
+ "primaryKey": false,
28
+ "notNull": true,
29
+ "autoincrement": false
30
+ },
31
+ "status": {
32
+ "name": "status",
33
+ "type": "text",
34
+ "primaryKey": false,
35
+ "notNull": true,
36
+ "autoincrement": false
37
+ },
38
+ "error_message": {
39
+ "name": "error_message",
40
+ "type": "text",
41
+ "primaryKey": false,
42
+ "notNull": false,
43
+ "autoincrement": false
44
+ },
45
+ "input_tokens": {
46
+ "name": "input_tokens",
47
+ "type": "integer",
48
+ "primaryKey": false,
49
+ "notNull": true,
50
+ "autoincrement": false,
51
+ "default": 0
52
+ },
53
+ "output_tokens": {
54
+ "name": "output_tokens",
55
+ "type": "integer",
56
+ "primaryKey": false,
57
+ "notNull": true,
58
+ "autoincrement": false,
59
+ "default": 0
60
+ },
61
+ "findings_count": {
62
+ "name": "findings_count",
63
+ "type": "integer",
64
+ "primaryKey": false,
65
+ "notNull": true,
66
+ "autoincrement": false,
67
+ "default": 0
68
+ },
69
+ "created_at": {
70
+ "name": "created_at",
71
+ "type": "text",
72
+ "primaryKey": false,
73
+ "notNull": true,
74
+ "autoincrement": false
75
+ }
76
+ },
77
+ "indexes": {},
78
+ "foreignKeys": {
79
+ "agent_results_session_id_review_sessions_id_fk": {
80
+ "name": "agent_results_session_id_review_sessions_id_fk",
81
+ "tableFrom": "agent_results",
82
+ "tableTo": "review_sessions",
83
+ "columnsFrom": [
84
+ "session_id"
85
+ ],
86
+ "columnsTo": [
87
+ "id"
88
+ ],
89
+ "onDelete": "no action",
90
+ "onUpdate": "no action"
91
+ }
92
+ },
93
+ "compositePrimaryKeys": {},
94
+ "uniqueConstraints": {},
95
+ "checkConstraints": {}
96
+ },
97
+ "project_profiles": {
98
+ "name": "project_profiles",
99
+ "columns": {
100
+ "id": {
101
+ "name": "id",
102
+ "type": "text",
103
+ "primaryKey": true,
104
+ "notNull": true,
105
+ "autoincrement": false
106
+ },
107
+ "workspace": {
108
+ "name": "workspace",
109
+ "type": "text",
110
+ "primaryKey": false,
111
+ "notNull": true,
112
+ "autoincrement": false
113
+ },
114
+ "repo": {
115
+ "name": "repo",
116
+ "type": "text",
117
+ "primaryKey": false,
118
+ "notNull": true,
119
+ "autoincrement": false
120
+ },
121
+ "default_model": {
122
+ "name": "default_model",
123
+ "type": "text",
124
+ "primaryKey": false,
125
+ "notNull": false,
126
+ "autoincrement": false
127
+ },
128
+ "agent_ids": {
129
+ "name": "agent_ids",
130
+ "type": "text",
131
+ "primaryKey": false,
132
+ "notNull": false,
133
+ "autoincrement": false
134
+ },
135
+ "conventions": {
136
+ "name": "conventions",
137
+ "type": "text",
138
+ "primaryKey": false,
139
+ "notNull": false,
140
+ "autoincrement": false
141
+ },
142
+ "created_at": {
143
+ "name": "created_at",
144
+ "type": "text",
145
+ "primaryKey": false,
146
+ "notNull": true,
147
+ "autoincrement": false
148
+ },
149
+ "updated_at": {
150
+ "name": "updated_at",
151
+ "type": "text",
152
+ "primaryKey": false,
153
+ "notNull": true,
154
+ "autoincrement": false
155
+ }
156
+ },
157
+ "indexes": {
158
+ "idx_profiles_workspace_repo": {
159
+ "name": "idx_profiles_workspace_repo",
160
+ "columns": [
161
+ "workspace",
162
+ "repo"
163
+ ],
164
+ "isUnique": true
165
+ }
166
+ },
167
+ "foreignKeys": {},
168
+ "compositePrimaryKeys": {},
169
+ "uniqueConstraints": {},
170
+ "checkConstraints": {}
171
+ },
172
+ "review_findings": {
173
+ "name": "review_findings",
174
+ "columns": {
175
+ "id": {
176
+ "name": "id",
177
+ "type": "text",
178
+ "primaryKey": true,
179
+ "notNull": true,
180
+ "autoincrement": false
181
+ },
182
+ "session_id": {
183
+ "name": "session_id",
184
+ "type": "text",
185
+ "primaryKey": false,
186
+ "notNull": true,
187
+ "autoincrement": false
188
+ },
189
+ "file_path": {
190
+ "name": "file_path",
191
+ "type": "text",
192
+ "primaryKey": false,
193
+ "notNull": true,
194
+ "autoincrement": false
195
+ },
196
+ "line_number": {
197
+ "name": "line_number",
198
+ "type": "integer",
199
+ "primaryKey": false,
200
+ "notNull": true,
201
+ "autoincrement": false
202
+ },
203
+ "severity": {
204
+ "name": "severity",
205
+ "type": "text",
206
+ "primaryKey": false,
207
+ "notNull": true,
208
+ "autoincrement": false
209
+ },
210
+ "category": {
211
+ "name": "category",
212
+ "type": "text",
213
+ "primaryKey": false,
214
+ "notNull": true,
215
+ "autoincrement": false
216
+ },
217
+ "title": {
218
+ "name": "title",
219
+ "type": "text",
220
+ "primaryKey": false,
221
+ "notNull": true,
222
+ "autoincrement": false
223
+ },
224
+ "problem": {
225
+ "name": "problem",
226
+ "type": "text",
227
+ "primaryKey": false,
228
+ "notNull": true,
229
+ "autoincrement": false
230
+ },
231
+ "rationale": {
232
+ "name": "rationale",
233
+ "type": "text",
234
+ "primaryKey": false,
235
+ "notNull": true,
236
+ "autoincrement": false
237
+ },
238
+ "suggestion": {
239
+ "name": "suggestion",
240
+ "type": "text",
241
+ "primaryKey": false,
242
+ "notNull": true,
243
+ "autoincrement": false
244
+ },
245
+ "agent_id": {
246
+ "name": "agent_id",
247
+ "type": "text",
248
+ "primaryKey": false,
249
+ "notNull": true,
250
+ "autoincrement": false
251
+ },
252
+ "dedup_hash": {
253
+ "name": "dedup_hash",
254
+ "type": "text",
255
+ "primaryKey": false,
256
+ "notNull": true,
257
+ "autoincrement": false
258
+ },
259
+ "status": {
260
+ "name": "status",
261
+ "type": "text",
262
+ "primaryKey": false,
263
+ "notNull": true,
264
+ "autoincrement": false,
265
+ "default": "'pending'"
266
+ },
267
+ "skip_reason": {
268
+ "name": "skip_reason",
269
+ "type": "text",
270
+ "primaryKey": false,
271
+ "notNull": false,
272
+ "autoincrement": false
273
+ },
274
+ "bitbucket_comment_id": {
275
+ "name": "bitbucket_comment_id",
276
+ "type": "integer",
277
+ "primaryKey": false,
278
+ "notNull": false,
279
+ "autoincrement": false
280
+ },
281
+ "created_at": {
282
+ "name": "created_at",
283
+ "type": "text",
284
+ "primaryKey": false,
285
+ "notNull": true,
286
+ "autoincrement": false
287
+ }
288
+ },
289
+ "indexes": {
290
+ "idx_findings_session": {
291
+ "name": "idx_findings_session",
292
+ "columns": [
293
+ "session_id"
294
+ ],
295
+ "isUnique": false
296
+ },
297
+ "idx_findings_hash": {
298
+ "name": "idx_findings_hash",
299
+ "columns": [
300
+ "dedup_hash"
301
+ ],
302
+ "isUnique": false
303
+ }
304
+ },
305
+ "foreignKeys": {
306
+ "review_findings_session_id_review_sessions_id_fk": {
307
+ "name": "review_findings_session_id_review_sessions_id_fk",
308
+ "tableFrom": "review_findings",
309
+ "tableTo": "review_sessions",
310
+ "columnsFrom": [
311
+ "session_id"
312
+ ],
313
+ "columnsTo": [
314
+ "id"
315
+ ],
316
+ "onDelete": "no action",
317
+ "onUpdate": "no action"
318
+ }
319
+ },
320
+ "compositePrimaryKeys": {},
321
+ "uniqueConstraints": {},
322
+ "checkConstraints": {}
323
+ },
324
+ "review_sessions": {
325
+ "name": "review_sessions",
326
+ "columns": {
327
+ "id": {
328
+ "name": "id",
329
+ "type": "text",
330
+ "primaryKey": true,
331
+ "notNull": true,
332
+ "autoincrement": false
333
+ },
334
+ "workspace": {
335
+ "name": "workspace",
336
+ "type": "text",
337
+ "primaryKey": false,
338
+ "notNull": true,
339
+ "autoincrement": false
340
+ },
341
+ "repo": {
342
+ "name": "repo",
343
+ "type": "text",
344
+ "primaryKey": false,
345
+ "notNull": true,
346
+ "autoincrement": false
347
+ },
348
+ "pr_id": {
349
+ "name": "pr_id",
350
+ "type": "integer",
351
+ "primaryKey": false,
352
+ "notNull": true,
353
+ "autoincrement": false
354
+ },
355
+ "pr_title": {
356
+ "name": "pr_title",
357
+ "type": "text",
358
+ "primaryKey": false,
359
+ "notNull": false,
360
+ "autoincrement": false
361
+ },
362
+ "pr_url": {
363
+ "name": "pr_url",
364
+ "type": "text",
365
+ "primaryKey": false,
366
+ "notNull": false,
367
+ "autoincrement": false
368
+ },
369
+ "status": {
370
+ "name": "status",
371
+ "type": "text",
372
+ "primaryKey": false,
373
+ "notNull": true,
374
+ "autoincrement": false,
375
+ "default": "'pending'"
376
+ },
377
+ "agent_ids": {
378
+ "name": "agent_ids",
379
+ "type": "text",
380
+ "primaryKey": false,
381
+ "notNull": true,
382
+ "autoincrement": false
383
+ },
384
+ "model": {
385
+ "name": "model",
386
+ "type": "text",
387
+ "primaryKey": false,
388
+ "notNull": true,
389
+ "autoincrement": false
390
+ },
391
+ "findings_count": {
392
+ "name": "findings_count",
393
+ "type": "integer",
394
+ "primaryKey": false,
395
+ "notNull": true,
396
+ "autoincrement": false,
397
+ "default": 0
398
+ },
399
+ "published_count": {
400
+ "name": "published_count",
401
+ "type": "integer",
402
+ "primaryKey": false,
403
+ "notNull": true,
404
+ "autoincrement": false,
405
+ "default": 0
406
+ },
407
+ "input_tokens": {
408
+ "name": "input_tokens",
409
+ "type": "integer",
410
+ "primaryKey": false,
411
+ "notNull": false,
412
+ "autoincrement": false
413
+ },
414
+ "output_tokens": {
415
+ "name": "output_tokens",
416
+ "type": "integer",
417
+ "primaryKey": false,
418
+ "notNull": false,
419
+ "autoincrement": false
420
+ },
421
+ "cost_usd": {
422
+ "name": "cost_usd",
423
+ "type": "real",
424
+ "primaryKey": false,
425
+ "notNull": false,
426
+ "autoincrement": false
427
+ },
428
+ "engram_saved": {
429
+ "name": "engram_saved",
430
+ "type": "integer",
431
+ "primaryKey": false,
432
+ "notNull": true,
433
+ "autoincrement": false,
434
+ "default": 0
435
+ },
436
+ "created_at": {
437
+ "name": "created_at",
438
+ "type": "text",
439
+ "primaryKey": false,
440
+ "notNull": true,
441
+ "autoincrement": false
442
+ },
443
+ "completed_at": {
444
+ "name": "completed_at",
445
+ "type": "text",
446
+ "primaryKey": false,
447
+ "notNull": false,
448
+ "autoincrement": false
449
+ }
450
+ },
451
+ "indexes": {},
452
+ "foreignKeys": {},
453
+ "compositePrimaryKeys": {},
454
+ "uniqueConstraints": {},
455
+ "checkConstraints": {}
456
+ }
457
+ },
458
+ "views": {},
459
+ "enums": {},
460
+ "_meta": {
461
+ "schemas": {},
462
+ "tables": {},
463
+ "columns": {}
464
+ },
465
+ "internal": {
466
+ "indexes": {}
467
+ }
468
+ }