eletrotupi / tcc/ api/prisma/schema.prisma96e7fe0f1dcc90b9ddef3032a78b7040d2068378
3.0 KB | 150 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], onDelete: Cascade)
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
  moment DateTime @default(now())
78

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

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

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

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

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

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

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

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

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

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

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

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

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