eletrotupi / tcc/ api/prisma/schema.prisma201b6a4401144f5c9158297d3500a8b4cf5d3f55
2.5 KB | 126 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
  description String? @db.Text
33
  moment DateTime @default(now())
34
  anxietyLevel Int @map("anxiety_level")
35
  stressLevel Int @map("stress_level")
36
  energyLevel Int @map("energy_level")
37
  userId Int @map("user_id")
38
  user User @relation(fields: [userId], references: [id])
39

40
  moodComponents MoodComponent[]
41

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

45
model MoodComponent {
46
  id Int @id @default(autoincrement())
47
  comment String?
48
  intensity IntensityLevel @default(LIGHT)
49

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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