forked from DimiMikadze/fest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
schema.prisma
82 lines (66 loc) · 2.05 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
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
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
enum OrganizationRole {
Member
Moderator
Admin
}
model User {
id String @id @default(cuid())
auth0Id String? @unique
googleId String? @unique
fullName String?
avatar String?
currentOrganizationId String?
email String @unique
emailVerified Boolean @default(false)
emailVerificationToken String?
emailVerificationCode String?
emailVerificationCodeExpires DateTime?
emailVerificationLinkSent Boolean @default(false)
// timestamps
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Relations
organizations OrganizationUser[]
invitations Invitation[]
}
model Organization {
id String @id @default(cuid())
name String @unique
logo String?
// timestamps
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
// Relations
members OrganizationUser[]
invitations Invitation[]
}
model OrganizationUser {
role OrganizationRole @default(Member)
// timestamps
assignedAt DateTime @default(now())
// relations
user User @relation(fields: [userId], references: [id], onUpdate: Cascade, onDelete: Cascade)
userId String
organization Organization @relation(fields: [organizationId], references: [id], onUpdate: Cascade, onDelete: Cascade)
organizationId String
@@id([userId, organizationId])
}
model Invitation {
id String @id @default(cuid())
role OrganizationRole @default(Member)
email String
inviteAccepted Boolean? @default(false)
token String?
// relations
inviter User @relation(fields: [inviterId], references: [id])
inviterId String
organization Organization @relation(fields: [organizationId], references: [id], onUpdate: Cascade, onDelete: Cascade)
organizationId String
}