-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathschema.prisma
More file actions
executable file
·135 lines (123 loc) · 3.79 KB
/
schema.prisma
File metadata and controls
executable file
·135 lines (123 loc) · 3.79 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
generator studio-client {
provider = "prisma-client-js"
binaryTargets = ["native"]
}
model Post {
id String @id
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String @db.VarChar(255)
content String?
published Boolean @default(false)
author User @relation(fields: [authorId], references: [id])
authorId String
}
model Profile {
id String @id
bio String?
user User @relation(fields: [userId], references: [id])
userId String @unique
}
model User {
id String @id
email String @unique
// username is an optional value, because it might create barrier when user signup.
username String? @unique
firstname String
lastname String
// A user might not have a password, if they login via OAuth.
hashedPassword String?
posts Post[]
profile Profile?
Repo Repo[] @relation("OWNER")
sharedRepos Repo[] @relation("COLLABORATOR")
githubAccessToken String?
}
model Repo {
id String @id
name String?
// fullname String @unique
owner User @relation("OWNER", fields: [userId], references: [id])
userId String
pods Pod[] @relation("BELONG")
podsId String[]
public Boolean @default(false)
collaborators User[] @relation("COLLABORATOR")
githubRepo String?
}
enum PodType {
CODE
SCOPE
DECK
WYSIWYG
MD
REPL
}
model Edge {
from Pod @relation("FROM", fields: [fromId], references: [id])
fromId String
to Pod @relation("TO", fields: [toId], references: [id])
toId String
@@id([fromId, toId])
}
model Pod {
id String @id
parent Pod? @relation("PARENT", fields: [parentId], references: [id])
parentId String?
x Float @default(0)
y Float @default(0)
width Float @default(0)
height Float @default(0)
index Int
// TODO how to specify the order of children
//
// Option 1:
// https://stackoverflow.com/questions/11094338/storing-item-positions-for-ordering-in-a-database-efficiently
// I can store a (position, timestamp). To udpate, just move the position, and
// use a new timestamp. The newer timestamp will ensure the correct order.
//
// What about
// - addition: OK
// - deletion: OK
// - deletion + insertion: seems OK
//
//
// Option 2:
// https://softwareengineering.stackexchange.com/questions/304593/how-to-store-ordered-information-in-a-relational-database
// Another option is to maintain the order of the pod, then, update all other
// pods after it.
children Pod[] @relation("PARENT")
content String?
// the HEAD version and STAGED version of pod content
githead String?
staged String?
column Int @default(1)
fold Boolean @default(false)
thundar Boolean @default(false)
utility Boolean @default(false)
name String?
lang String?
type PodType
result String?
stdout String?
error String?
imports String?
exports String?
midports String?
reexports String?
// repo Repo? @relation("ROOT")
repo Repo @relation("BELONG", fields: [repoId], references: [id])
repoId String
// this is just a place holder. Not useful
to Edge[] @relation("TO")
from Edge[] @relation("FROM")
}