-
Notifications
You must be signed in to change notification settings - Fork 5
/
schema.prisma
69 lines (55 loc) · 2.23 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
datasource db {
provider = "postgresql"
url = env("DB_CONNECTION_STRING")
}
generator client {
provider = "prisma-client-js"
}
// ---------------------- ENUMS
enum UserRole {
USER
ADMIN
MODERATOR
}
enum NotificationType {
WELCOME
TEST
}
// ---------------------- MODELS
model User {
id String @id @db.VarChar(28)
userName String @unique @map("user_name") @db.VarChar(25)
firstName String @map("first_name") @db.VarChar(50)
lastName String @map("last_name") @db.VarChar(50)
role UserRole @default(USER)
photoURL String? @map("photo_url") @db.VarChar(300)
isPushNotificationsEnabled Boolean @default(false) @map("is_push_notifications_enabled")
lastTimeSignedIn DateTime @default(now()) @map("last_time_signed_in")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
userDevices UserDevice[]
notifications Notification[]
@@map(name: "users")
}
model UserDevice {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.VarChar(36)
userId String @map("user_id") @db.VarChar(28)
fcmToken String @map("fcm_token") @db.VarChar(256)
deviceId String? @map("device_id") @db.VarChar(50)
deviceName String? @map("device_name") @db.VarChar(50)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@unique([fcmToken, userId])
@@map(name: "user_devices")
}
model Notification {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.VarChar(36)
type NotificationType
isRead Boolean @default(false) @map("is_read")
userId String @map("user_id") @db.VarChar(28)
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @default(now()) @updatedAt @map("updated_at")
user User @relation(fields: [userId], references: [id], onDelete: Cascade, onUpdate: Cascade)
@@map(name: "notifications")
}