eletrotupi / tcc/ api/prisma/schema.prisma0e69b3981ab74bef567c19220d0b6dc95b9e909f
3.1 KB | 155 lines Raw
1
generator client {
2
  provider = "prisma-client-js"
3
  //output   = "../src/generated/prisma"
4
}
5

6
datasource db {
7
  provider = "postgresql"
8
}
9

10
model User {
11
  id Int @id @default(autoincrement())
12
  firstName String @map("first_name")
13
  lastName String? @map("last_name")
14
  email String @unique
15
  encryptedPassword String @map("encrypted_password")
16
  passwordResetToken String? @map("password_reset_token")
17
  passwordResetExpires DateTime? @map("password_reset_expires")
18
  createdAt DateTime @default(now()) @map("created_at")
19
  updatedAt DateTime @updatedAt @map("updated_at")
20
  avatarKey String? @map("avatar_key")
21
  avatarURL String? @map("avatar_url")
22

23
  activationCode String? @map("activation_code")
24
  activationCodeExpiresAt DateTime? @map("activation_code_expires_at")
25
  active Boolean @default(false) @map("active")
26

27
  moods Mood[]
28
  interventions Intervention[]
29
  triggers Trigger[]
30
  reminders Reminder[]
31
  sleepRecords SleepRecord[]
32

33
  @@map("users")
34
}
35

36
model Mood {
37
  id Int @id @default(autoincrement())
38
  annotation String? @db.Text
39
  moment DateTime @default(now())
40
  selectedMood BaseMoodOption @default(GOOD) @map("selected_mood")
41
  anxietyLevel Int @map("anxiety_level")
42
  stressLevel Int @map("stress_level")
43
  energyLevel Int @map("energy_level")
44
  userId Int @map("user_id")
45
  user User @relation(fields: [userId], references: [id])
46

47
  moodComponents MoodComponent[]
48

49
  @@map("moods")
50
}
51

52
model MoodComponent {
53
  id Int @id @default(autoincrement())
54
  component MoodComponentOption
55
  intensity IntensityLevel @default(LIGHT)
56

57
  moodId Int @map("mood_id")
58
  mood Mood @relation(fields: [moodId], references: [id], onDelete: Cascade)
59

60
  @@map("mood_components")
61
}
62

63
model Intervention {
64
  id Int @id @default(autoincrement())
65
	comment String?
66
	interventionType InterventionType @map("intervention_type")
67
	eficacy Int
68
  startAt DateTime @map("start_at")
69
  endAt DateTime @map("end_at")
70

71
  userId Int @map("user_id")
72
  user User @relation(fields: [userId], references: [id])
73

74
  @@map("interventions")
75
}
76

77
model Trigger {
78
  id Int @id @default(autoincrement())
79
	comment String? @db.Text
80
	category TriggerType
81
  moment DateTime @default(now())
82

83
  userId Int @map("user_id")
84
  user User @relation(fields: [userId], references: [id])
85

86
  @@map("triggers")
87
}
88

89
model Reminder {
90
  id Int @id @default(autoincrement())
91
  hour Int
92
  minute Int
93
  description String?
94
  active Boolean @default(false)
95

96
  userId Int @map("user_id")
97
  user User @relation(fields: [userId], references: [id])
98

99
  @@map("reminders")
100
}
101

102
model SleepRecord {
103
  id Int @id @default(autoincrement())
104
  average Float
105
  date DateTime @db.Date
106
  annotations String? @db.Text
107

108
  userId Int @map("user_id")
109
  user User @relation(fields: [userId], references: [id])
110

111
  @@map("sleep_records")
112
}
113

114
enum IntensityLevel {
115
  LIGHT
116
  MODERATE
117
  HIGH
118
}
119

120
enum InterventionType {
121
  MEDICATION
122
  THERAPY
123
  MEDITATION
124
  EXERCISE
125
  CONVERSATION
126
}
127

128
enum TriggerType {
129
  SOCIAL
130
  WORK
131
  HEALTH
132
  PHYSICAL
133
  FAMILY
134
  OTHER
135
}
136

137
// XXX: Keep it in sync with constants/moods.ts
138
enum BaseMoodOption {
139
  SAD
140
  NEUTRAL
141
  GOOD
142
  GREAT
143
  ANGRY
144
}
145

146
enum MoodComponentOption {
147
  JOY
148
  NEUTRAL
149
  ANGER
150
  SADNESS
151
  ANXIETY
152
  GRATITUDE
153
  FOCUS
154
  TIREDNESS
155
}