/
schema.prisma
57 lines (50 loc) · 1.44 KB
/
schema.prisma
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
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
relationMode = "prisma"
}
generator js {
provider = "prisma-client-js"
binaryTargets = ["native"]
}
model ReplicacheClient {
// --- PUBLIC ID ---
replicacheClientId String @unique
// --- FIELDS ---
lastMutationId Int @default(0)
}
// Replicache syncs “spaces”, i.e. groups of related data (such as to-dos and their connected categories)
model Space {
// --- SYSTEM ---
versionAt Int @default(0)
// --- PUBLIC ID ---
spaceId String @unique
// --- RELATIONS ---
todos Todo[] @relation("RSpaceToTodos")
user User @relation("RUserToSpaces", fields: [userId], references: [userId], onDelete: Cascade)
userId String
@@index([userId])
}
model Todo {
// --- SYSTEM ---
versionUpdatedAt Int @default(0)
// --- PUBLIC ID ---
todoId String @unique
// --- RELATIONS ---
space Space @relation("RSpaceToTodos", fields: [spaceId], references: [spaceId], onDelete: Cascade)
spaceId String
// --- FIELDS ---
isDeleted Boolean @default(false)
name String?
sortOrder Int @default(0)
@@index([spaceId])
}
model User {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// --- PUBLIC ID ---
userId String @unique
// --- RELATIONS ---
spaces Space[] @relation("RUserToSpaces")
}