eletrotupi / tcc/ commit / 6b750ae

api: add reminders relationship to users

Pedro Lucas Porcellis porcellis@eletrotupi.com · 5 months ago 6b750ae3fe751d53eedd5713de5678c40cf90df9 Browse files
Parents b4d55cb
Changed files
2
Additions
+15
Deletions
0
/dev/null → api/prisma/migrations/20260504225524_add_reminders_relationship_to_users/migration.sql
1 +
/*
2 +
  Warnings:
3 +

4 +
  - Added the required column `user_id` to the `reminders` table without a default value. This is not possible if the table is not empty.
5 +

6 +
*/
7 +
-- AlterTable
8 +
ALTER TABLE "reminders" ADD COLUMN     "user_id" INTEGER NOT NULL;
9 +

10 +
-- AddForeignKey
11 +
ALTER TABLE "reminders" ADD CONSTRAINT "reminders_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

19 19
  updatedAt DateTime @updatedAt @map("updated_at")
20 20

21 21
  moods Mood[]
22 22
  interventions Intervention[]
23 23
  triggers Trigger[]
24 +
  reminders Reminder[]
24 25

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

28 29
model Mood {
80 81
  id Int @id @default(autoincrement())
81 82
  hour Int
82 83
  minute Int
83 84
  description String?
84 85
  active Boolean @default(false)
86 +

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

86 90
  @@map("reminders")
87 91
}
88 92

89 93
enum IntensityLevel {
105 109
  ENVIRONMENTAL
106 110
  EMOTIONAL
107 111
  PHYSICAL
108 112
  OTHER
109 113
}