-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.ts
More file actions
68 lines (62 loc) · 1.8 KB
/
Copy pathschema.ts
File metadata and controls
68 lines (62 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { column, Schema, Table } from '@powersync/web';
/**
* PowerSync client-side schema.
* Maps to the synced Postgres tables: projects, lessons, questions.
* DO NOT define 'id' — PowerSync creates it automatically as TEXT PRIMARY KEY.
*/
const projects = new Table({
name: column.text,
slug: column.text,
description: column.text,
created_at: column.text,
});
const lessons = new Table(
{
project_id: column.text,
title: column.text,
problem: column.text,
root_cause: column.text,
solution: column.text,
recommendation: column.text,
tags: column.text,
source_type: column.text,
source_ref: column.text,
created_at: column.text,
risk_level: column.text,
antipattern_name: column.text,
antipattern_reason: column.text,
},
{ indexes: { project: ['project_id'] } }
);
const questions = new Table(
{
project_id: column.text,
question: column.text,
answer: column.text,
sources: column.text,
created_at: column.text,
},
{ indexes: { project: ['project_id'] } }
);
const ingest_jobs = new Table(
{
project_id: column.text,
storage_path: column.text,
file_name: column.text,
category: column.text,
status: column.text,
error: column.text,
document_id: column.text,
progress: column.integer,
created_at: column.text,
updated_at: column.text,
},
{ indexes: { project: ['project_id'], status: ['status'] } }
);
export const appSchema = new Schema({ projects, lessons, questions, ingest_jobs });
/** Derive TypeScript row types directly from the schema. */
export type Database = (typeof appSchema)['types'];
export type ProjectRow = Database['projects'];
export type LessonRow = Database['lessons'];
export type QuestionRow = Database['questions'];
export type IngestJobRow = Database['ingest_jobs'];