eletrotupi / tcc/ api/prisma/schema.prisma23c0d375c6007bb31f664fa3b208e18023c04ba7
2.8 KB | 147 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

21
  moods Mood[]
22
  interventions Intervention[]
23
  triggers Trigger[]
24
  reminders Reminder[]
25
  sleepRecords SleepRecord[]
26

27
  @@map("users")
28
}
29

30
model Mood {
31
  id Int @id @default(autoincrement())
32
  annotation String? @db.Text
33
  moment DateTime @default(now())
34
  selectedMood BaseMoodOption @default(GOOD) @map("selected_mood")
35
  anxietyLevel Int @map("anxiety_level")
36
  stressLevel Int @map("stress_level")
37
  energyLevel Int @map("energy_level")
38
  userId Int @map("user_id")
39
  user User @relation(fields: [userId], references: [id])
40

41
  moodComponents MoodComponent[]
42

43
  @@map("moods")
44
}
45

46
model MoodComponent {
47
  id Int @id @default(autoincrement())
48
  component MoodComponentOption
49
  intensity IntensityLevel @default(LIGHT)
50

51
  moodId Int @map("mood_id")
52
  mood Mood @relation(fields: [moodId], references: [id])
53

54
  @@map("mood_components")
55
}
56

57
model Intervention {
58
  id Int @id @default(autoincrement())
59
	comment String?
60
	interventionType InterventionType @map("intervention_type")
61
	eficacy Int
62
  startAt DateTime @map("start_at")
63
  endAt DateTime @map("end_at")
64

65
  userId Int @map("user_id")
66
  user User @relation(fields: [userId], references: [id])
67

68
  @@map("interventions")
69
}
70

71
model Trigger {
72
  id Int @id @default(autoincrement())
73
	comment String? @db.Text
74
	category TriggerType
75

76
  userId Int @map("user_id")
77
  user User @relation(fields: [userId], references: [id])
78

79
  @@map("triggers")
80
}
81

82
model Reminder {
83
  id Int @id @default(autoincrement())
84
  hour Int
85
  minute Int
86
  description String?
87
  active Boolean @default(false)
88

89
  userId Int @map("user_id")
90
  user User @relation(fields: [userId], references: [id])
91

92
  @@map("reminders")
93
}
94

95
model SleepRecord {
96
  id Int @id @default(autoincrement())
97
  average Float
98
  date DateTime @db.Date
99
  annotations String? @db.Text
100

101
  userId Int @map("user_id")
102
  user User @relation(fields: [userId], references: [id])
103

104
  @@map("sleep_records")
105
}
106

107
enum IntensityLevel {
108
  LIGHT
109
  MODERATE
110
  HIGH
111
}
112

113
enum InterventionType {
114
  MEDICATION
115
  THERAPY
116
  MEDITATION
117
  EXERCISE
118
  CONVERSATION
119
}
120

121
enum TriggerType {
122
  SOCIAL
123
  ENVIRONMENTAL
124
  EMOTIONAL
125
  PHYSICAL
126
  OTHER
127
}
128

129
// XXX: Keep it in sync with constants/moods.ts
130
enum BaseMoodOption {
131
  SAD
132
  NEUTRAL
133
  GOOD
134
  GREAT
135
  ANGRY
136
}
137

138
enum MoodComponentOption {
139
  JOY
140
  NEUTRAL
141
  ANGER
142
  SADNESS
143
  ANXIETY
144
  GRATITUDE
145
  FOCUS
146
  TIREDNESS
147
}