api: add reminders relationship to users

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago 6b750ae3fe751d53eedd5713de5678c40cf90df9
Parents: b4d55cb
2 file(s) changed
  • api/prisma/migrations/20260504225524_add_reminders_relationship_to_users/migration.sql +11 -0
  • api/prisma/schema.prisma +4 -0
api/prisma/migrations/20260504225524_add_reminders_relationship_to_users/migration.sql
@@ -0,0 +1,11 @@
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
@@ -21,6 +21,7 @@
21 21 moods Mood[]
22 22 interventions Intervention[]
23 23 triggers Trigger[]
24 + reminders Reminder[]
24 25
25 26 @@map("users")
26 27 }
@@ -82,6 +83,9 @@ 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 }