eletrotupi / tcc/ api/prisma/schema.prismab4d55cb6c0798e104724a081ee5745a111ff3b6e
2.2 KB | 109 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

25
  @@map("users")
26
}
27

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

38
  moodComponents MoodComponent[]
39

40
  @@map("moods")
41
}
42

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

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

51
  @@map("mood_components")
52
}
53

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

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

65
  @@map("interventions")
66
}
67

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

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

76
  @@map("triggers")
77
}
78

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

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

89
enum IntensityLevel {
90
  LIGHT
91
  MODERATE
92
  HIGH
93
}
94

95
enum InterventionType {
96
  MEDICATION
97
  THERAPY
98
  MEDITATION
99
  EXERCISE
100
  CONVERSATION
101
}
102

103
enum TriggerType {
104
  SOCIAL
105
  ENVIRONMENTAL
106
  EMOTIONAL
107
  PHYSICAL
108
  OTHER
109
}