eletrotupi / tcc/ api/prisma/schema.prisma94a9e9492999dae406897bdab0c1e6e25eabe0cb
2.9 KB | 149 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
  moods Mood[]
24
  interventions Intervention[]
25
  triggers Trigger[]
26
  reminders Reminder[]
27
  sleepRecords SleepRecord[]
28

29
  @@map("users")
30
}
31

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

43
  moodComponents MoodComponent[]
44

45
  @@map("moods")
46
}
47

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

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

56
  @@map("mood_components")
57
}
58

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

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

70
  @@map("interventions")
71
}
72

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

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

81
  @@map("triggers")
82
}
83

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

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

94
  @@map("reminders")
95
}
96

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

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

106
  @@map("sleep_records")
107
}
108

109
enum IntensityLevel {
110
  LIGHT
111
  MODERATE
112
  HIGH
113
}
114

115
enum InterventionType {
116
  MEDICATION
117
  THERAPY
118
  MEDITATION
119
  EXERCISE
120
  CONVERSATION
121
}
122

123
enum TriggerType {
124
  SOCIAL
125
  ENVIRONMENTAL
126
  EMOTIONAL
127
  PHYSICAL
128
  OTHER
129
}
130

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

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