eletrotupi / tcc/ commit / 95520d8

api: add interventions

Pedro Lucas Porcellis porcellis@eletrotupi.com · 6 months ago 95520d874f28f49a762a222a2ab593de585a0436 Browse files
Parents 81ea07a
Changed files
2
Additions
+41
Deletions
0
/dev/null → api/prisma/migrations/20260427224658_create_interventions/migration.sql
1 +
-- CreateEnum
2 +
CREATE TYPE "InterventionType" AS ENUM ('MEDICATION', 'THERAPY', 'MEDITATION', 'EXERCISE', 'CONVERSATION');
3 +

4 +
-- CreateTable
5 +
CREATE TABLE "interventions" (
6 +
    "id" SERIAL NOT NULL,
7 +
    "comment" TEXT,
8 +
    "intervention_type" "InterventionType" NOT NULL,
9 +
    "eficacy" INTEGER NOT NULL,
10 +
    "start_at" TIMESTAMP(3) NOT NULL,
11 +
    "end_at" TIMESTAMP(3) NOT NULL,
12 +
    "user_id" INTEGER NOT NULL,
13 +

14 +
    CONSTRAINT "interventions_pkey" PRIMARY KEY ("id")
15 +
);
16 +

17 +
-- AddForeignKey
18 +
ALTER TABLE "interventions" ADD CONSTRAINT "interventions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
api/prisma/schema.prisma
1 1
generator client {
2 2
  provider = "prisma-client-js"
3 3
  //output   = "../src/generated/prisma"
4 4
}
5 5

17 17
  passwordResetExpires DateTime? @map("password_reset_expires")
18 18
  createdAt DateTime @default(now()) @map("created_at")
19 19
  updatedAt DateTime @updatedAt @map("updated_at")
20 20

21 21
  moods Mood[]
22 +
  interventions Intervention[]
22 23

23 24
  @@map("users")
24 25
}
25 26

26 27
model Mood {
47 48
  mood Mood @relation(fields: [moodId], references: [id])
48 49

49 50
  @@map("mood_components")
50 51
}
51 52

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

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

64 +
  @@map("interventions")
65 +
}
66 +

52 67
enum IntensityLevel {
53 68
  LIGHT
54 69
  MODERATE
55 70
  HIGH
56 71
}
72 +

73 +
enum InterventionType {
74 +
  MEDICATION
75 +
  THERAPY
76 +
  MEDITATION
77 +
  EXERCISE
78 +
  CONVERSATION
79 +
}