api: fine tuning mood and mood component options
Pedro Lucas Porcellis porcellis@eletrotupi.com · 5 months ago
e6ef56c1b0011e63ffcd895b0c27b27ea609d7ad Browse filesParents
8866389Changed files
3
Additions
+49
Deletions
-2
/dev/null → api/prisma/migrations/20260513034950_fine_tuning_mood_and_mood_components/migration.sql
1 +
/*
2 +
Warnings:
3 +
4 +
- You are about to drop the column `description` on the `moods` table. All the data in the column will be lost.
5 +
6 +
*/
7 +
-- CreateEnum
8 +
CREATE TYPE "BaseMoodOption" AS ENUM ('SAD', 'NEUTRAL', 'GOOD', 'GREAT', 'ANGRY');
9 +
10 +
-- AlterTable
11 +
ALTER TABLE "moods" DROP COLUMN "description",
12 +
ADD COLUMN "annotation" TEXT,
13 +
ADD COLUMN "selected_mood" "BaseMoodOption" NOT NULL DEFAULT 'GOOD';
/dev/null → api/prisma/migrations/20260513035254_map_mood_component_options/migration.sql
1 +
/*
2 +
Warnings:
3 +
4 +
- You are about to drop the column `comment` on the `mood_components` table. All the data in the column will be lost.
5 +
- Added the required column `component` to the `mood_components` table without a default value. This is not possible if the table is not empty.
6 +
7 +
*/
8 +
-- CreateEnum
9 +
CREATE TYPE "MoodComponentOption" AS ENUM ('JOY', 'NEUTRAL', 'ANGER', 'SADNESS', 'ANXIETY', 'GRATITUDE', 'FOCUS', 'TIREDNESS');
10 +
11 +
-- AlterTable
12 +
ALTER TABLE "mood_components" DROP COLUMN "comment",
13 +
ADD COLUMN "component" "MoodComponentOption" NOT NULL;
api/prisma/schema.prisma
1 1
generator client {
2 2
provider = "prisma-client-js"
3 3
//output = "../src/generated/prisma"
4 4
}
5 5
27 27
@@map("users")
28 28
}
29 29
30 30
model Mood {
31 31
id Int @id @default(autoincrement())
32 -
description String? @db.Text
32 +
annotation String? @db.Text
33 33
moment DateTime @default(now())
34 +
selectedMood BaseMoodOption @default(GOOD) @map("selected_mood")
34 35
anxietyLevel Int @map("anxiety_level")
35 36
stressLevel Int @map("stress_level")
36 37
energyLevel Int @map("energy_level")
37 38
userId Int @map("user_id")
38 39
user User @relation(fields: [userId], references: [id])
42 43
@@map("moods")
43 44
}
44 45
45 46
model MoodComponent {
46 47
id Int @id @default(autoincrement())
47 -
comment String?
48 +
component MoodComponentOption
48 49
intensity IntensityLevel @default(LIGHT)
49 50
50 51
moodId Int @map("mood_id")
51 52
mood Mood @relation(fields: [moodId], references: [id])
52 53
122 123
ENVIRONMENTAL
123 124
EMOTIONAL
124 125
PHYSICAL
125 126
OTHER
126 127
}
128 +
129 +
// XXX: Keep it in sync with constants/moods.ts
130 +
enum BaseMoodOption {
131 +
SAD
132 +
NEUTRAL
133 +
GOOD
134 +
GREAT
135 +
ANGRY
136 +
}
137 +
138 +
enum MoodComponentOption {
139 +
JOY
140 +
NEUTRAL
141 +
ANGER
142 +
SADNESS
143 +
ANXIETY
144 +
GRATITUDE
145 +
FOCUS
146 +
TIREDNESS
147 +
}