api: fine tuning mood and mood component options
Parents:
88663893 file(s) changed
- api/prisma/migrations/20260513034950_fine_tuning_mood_and_mood_components/migration.sql +13 -0
- api/prisma/migrations/20260513035254_map_mood_component_options/migration.sql +13 -0
- api/prisma/schema.prisma +23 -2
api/prisma/migrations/20260513034950_fine_tuning_mood_and_mood_components/migration.sql
@@ -0,0 +1,13 @@
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';
api/prisma/migrations/20260513035254_map_mood_component_options/migration.sql
@@ -0,0 +1,13 @@
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
@@ -29,8 +29,9 @@ }
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")
@@ -44,7 +45,7 @@ }
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")
@@ -124,3 +125,23 @@ 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 + }