Bug fixes and refactoring
This commit is contained in:
BIN
server/prisma/prisma/dev.db
Normal file
BIN
server/prisma/prisma/dev.db
Normal file
Binary file not shown.
BIN
server/prisma/prisma/dev.db-journal
Normal file
BIN
server/prisma/prisma/dev.db-journal
Normal file
Binary file not shown.
118
server/prisma/schema.migrate.prisma
Normal file
118
server/prisma/schema.migrate.prisma
Normal file
@@ -0,0 +1,118 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
||||
|
||||
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
email String @unique
|
||||
password String
|
||||
role String @default("USER") // USER, ADMIN
|
||||
isFirstLogin Boolean @default(true)
|
||||
isBlocked Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
profile UserProfile?
|
||||
sessions WorkoutSession[]
|
||||
exercises Exercise[]
|
||||
plans WorkoutPlan[]
|
||||
weightRecords BodyWeightRecord[]
|
||||
}
|
||||
|
||||
model BodyWeightRecord {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
weight Float
|
||||
date DateTime @default(now())
|
||||
dateStr String // YYYY-MM-DD for unique constraint
|
||||
|
||||
@@unique([userId, dateStr])
|
||||
}
|
||||
|
||||
model UserProfile {
|
||||
id String @id @default(uuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
weight Float?
|
||||
height Float?
|
||||
gender String?
|
||||
birthDate DateTime?
|
||||
language String? @default("en")
|
||||
}
|
||||
|
||||
model Exercise {
|
||||
id String @id @default(uuid())
|
||||
userId String? // Null means system default
|
||||
user User? @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
type String // STRENGTH, CARDIO, BODYWEIGHT, STATIC
|
||||
bodyWeightPercentage Float? @default(0)
|
||||
isArchived Boolean @default(false)
|
||||
isUnilateral Boolean @default(false)
|
||||
|
||||
sets WorkoutSet[]
|
||||
planExercises PlanExercise[]
|
||||
}
|
||||
|
||||
model WorkoutSession {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
startTime DateTime
|
||||
endTime DateTime?
|
||||
userBodyWeight Float?
|
||||
note String?
|
||||
planId String?
|
||||
planName String?
|
||||
type String @default("STANDARD") // STANDARD, QUICK_LOG
|
||||
|
||||
sets WorkoutSet[]
|
||||
}
|
||||
|
||||
model WorkoutSet {
|
||||
id String @id @default(uuid())
|
||||
sessionId String
|
||||
session WorkoutSession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
||||
exerciseId String
|
||||
exercise Exercise @relation(fields: [exerciseId], references: [id])
|
||||
|
||||
order Int
|
||||
weight Float?
|
||||
reps Int?
|
||||
distanceMeters Float?
|
||||
durationSeconds Int?
|
||||
height Float?
|
||||
bodyWeightPercentage Float?
|
||||
completed Boolean @default(true)
|
||||
side String? // LEFT, RIGHT, or null for bilateral
|
||||
timestamp DateTime @default(now())
|
||||
}
|
||||
|
||||
model WorkoutPlan {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
name String
|
||||
description String?
|
||||
exercises String? // JSON string of exercise IDs (Deprecated, to be removed)
|
||||
planExercises PlanExercise[]
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model PlanExercise {
|
||||
id String @id @default(uuid())
|
||||
planId String
|
||||
plan WorkoutPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
exerciseId String
|
||||
exercise Exercise @relation(fields: [exerciseId], references: [id])
|
||||
order Int
|
||||
isWeighted Boolean @default(false)
|
||||
}
|
||||
Reference in New Issue
Block a user