@@ -6,108 +6,18 @@ generator client {
66}
77
88datasource db {
9- provider = " postgresql "
9+ provider = " sqlite "
1010 url = env (" DATABASE_URL " )
1111}
1212
13- model User {
14- id String @id @default (uuid () )
15- username String @unique
16- registrationRecord String
17- sessions Session []
18- loginAttempt LoginAttempt ?
19- createdAt DateTime @default (now () )
20- documents UsersOnDocuments []
21- userLocker UserLocker []
13+ model SpaceEvent {
14+ id String @id
15+ event String
16+ space Space @relation (fields : [spaceId ] , references : [id ] )
17+ spaceId String
2218}
2319
24- model UserLocker {
25- id String @id @default (uuid () )
26- userId String
27- user User @relation (fields : [userId ] , references : [id ] )
28- clock Int
29- ciphertext String
30- nonce String
31- commitment String
32- createdAt DateTime @default (now () )
33-
34- @@unique ([userId , clock ] )
35- }
36-
37- model Session {
38- token String @id
39- sessionKey String
40- userId String
41- user User @relation (fields : [userId ] , references : [id ] )
42- createdAt DateTime @default (now () )
43- }
44-
45- model LoginAttempt {
46- id String @id @default (uuid () )
47- userId String @unique
48- user User @relation (fields : [userId ] , references : [id ] )
49- serverLoginState String
50- createdAt DateTime @default (now () )
51- }
52-
53- model UsersOnDocuments {
54- user User @relation (fields : [userId ] , references : [id ] )
55- userId String
56- document Document @relation (fields : [documentId ] , references : [id ] )
57- documentId String
58- isAdmin Boolean
59-
60- @@id ([userId , documentId ] )
61- }
62-
63- model DocumentInvitation {
64- id String @id @default (uuid () )
65- document Document @relation (fields : [documentId ] , references : [id ] )
66- documentId String
67- token String @unique
68- createdAt DateTime @default (now () )
69- ciphertext String
70- }
71-
72- model Document {
73- id String @id
74- nameCiphertext String
75- nameNonce String
76- nameCommitment String
77- createdAt DateTime @default (now () )
78- updatedAt DateTime @updatedAt
79- users UsersOnDocuments []
80- documentInvitations DocumentInvitation []
81- activeSnapshot Snapshot ? @relation (name : " activeSnapshot " , fields : [activeSnapshotId ] , references : [id ] )
82- activeSnapshotId String ? @unique
83- snapshots Snapshot []
84- }
85-
86- model Snapshot {
87- id String @id
88- latestVersion Int
89- data String
90- ciphertextHash String
91- document Document @relation (fields : [documentId ] , references : [id ] )
92- documentId String
93- updates Update []
94- activeSnapshotDocument Document ? @relation (" activeSnapshot " )
95- createdAt DateTime @default (now () )
96- clocks Json
97- parentSnapshotUpdateClocks Json
98- parentSnapshotProof String
99- }
100-
101- model Update {
102- id String @unique // composed out of snapshotId, pubKey, clock
103- version Int
104- data String
105- snapshot Snapshot @relation (fields : [snapshotId ] , references : [id ] )
106- snapshotId String
107- clock Int
108- pubKey String
109-
110- @@unique ([snapshotId , version ] )
111- @@unique ([snapshotId , pubKey , clock ] ) // matches the id
112- @@index ([id , version ] )
20+ model Space {
21+ id String @id
22+ events SpaceEvent []
11323}
0 commit comments