From 0729ef0b7da0015264440d05b8011371705cb3b5 Mon Sep 17 00:00:00 2001 From: thedemonsid Date: Thu, 25 Jul 2024 10:18:41 +0530 Subject: [PATCH] chore: Add MovementType and TargetMuscle enums to schema and migration --- .../migration.sql | 20 +++++++++++ prisma/schema.prisma | 34 +++++++++++++++++-- src/lib/data/workout.js | 0 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 prisma/migrations/20240725044812_movement_type/migration.sql create mode 100644 src/lib/data/workout.js diff --git a/prisma/migrations/20240725044812_movement_type/migration.sql b/prisma/migrations/20240725044812_movement_type/migration.sql new file mode 100644 index 0000000..edb5989 --- /dev/null +++ b/prisma/migrations/20240725044812_movement_type/migration.sql @@ -0,0 +1,20 @@ +/* + Warnings: + + - You are about to drop the column `how_to_make` on the `meals` table. All the data in the column will be lost. + - Made the column `imageUrl` on table `meals` required. This step will fail if there are existing NULL values in that column. + +*/ +-- CreateEnum +CREATE TYPE "MovementType" AS ENUM ('PUSH', 'PULL', 'LEGS', 'CORE', 'FULL_BODY'); + +-- CreateEnum +CREATE TYPE "TargetMuscle" AS ENUM ('CHEST', 'BACK', 'SHOULDERS', 'BICEPS', 'TRICEPS', 'FOREARMS', 'ABS', 'QUADS', 'HAMSTRINGS', 'CALVES', 'GLUTES', 'ADDUCTORS', 'ABDUCTORS', 'TRAPS', 'LATS', 'LOWER_BACK'); + +-- AlterTable +ALTER TABLE "meals" DROP COLUMN "how_to_make", +ALTER COLUMN "imageUrl" SET NOT NULL; + +-- AlterTable +ALTER TABLE "workouts" ADD COLUMN "movementType" "MovementType" NOT NULL DEFAULT 'FULL_BODY', +ADD COLUMN "targetMuscle" "TargetMuscle"[]; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 1d86a66..6bbb56d 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -69,14 +69,13 @@ model MealInstance { model Meal { id String @id @default(cuid()) name String @unique - howToMake String @map(name: "how_to_make") + recipe String? calories Float @default(0) protein Float @default(0) carbs Float @default(0) fats Float @default(0) fiber Float @default(0) - recipe String? - imageUrl String? + imageUrl String videoUrl String? createdAt DateTime @default(now()) @map(name: "created_at") updatedAt DateTime @updatedAt @map(name: "updated_at") @@ -123,6 +122,8 @@ model Workout { name String @unique howToDo String @map(name: "how_to_do") duration Int + movementType MovementType @default(FULL_BODY) + targetMuscle TargetMuscle[] difficulty Difficulty @default(BEGINNER) imageUrl String videoUrl String @@ -138,3 +139,30 @@ enum Difficulty { INTERMEDIATE ADVANCED } + +enum MovementType { + PUSH + PULL + LEGS + CORE + FULL_BODY +} + +enum TargetMuscle { + CHEST + BACK + SHOULDERS + BICEPS + TRICEPS + FOREARMS + ABS + QUADS + HAMSTRINGS + CALVES + GLUTES + ADDUCTORS + ABDUCTORS + TRAPS + LATS + LOWER_BACK +} diff --git a/src/lib/data/workout.js b/src/lib/data/workout.js new file mode 100644 index 0000000..e69de29