Plany: wizard 3-etapowy tworzenia/edycji, silownia i alias tygodnia (UX + API + migracja)
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "PlanWeek" ADD COLUMN "customName" TEXT;
|
||||
|
||||
-- AlterTable
|
||||
ALTER TABLE "TrainingPlan" ADD COLUMN "gymId" TEXT;
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "TrainingPlan_gymId_idx" ON "TrainingPlan"("gymId");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "TrainingPlan" ADD CONSTRAINT "TrainingPlan_gymId_fkey" FOREIGN KEY ("gymId") REFERENCES "Gym"("id") ON DELETE SET NULL ON UPDATE CASCADE;
|
||||
@@ -85,45 +85,45 @@ enum EquipmentKind {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
passwordHash String
|
||||
firstName String?
|
||||
lastName String?
|
||||
nickname String?
|
||||
socialMedia Json?
|
||||
age Int?
|
||||
heightCm Float?
|
||||
phone String? @unique
|
||||
isAdmin Boolean @default(false)
|
||||
tokenVersion Int @default(0)
|
||||
availability Json?
|
||||
priorities String?
|
||||
exclusions String?
|
||||
id String @id @default(cuid())
|
||||
email String @unique
|
||||
passwordHash String
|
||||
firstName String?
|
||||
lastName String?
|
||||
nickname String?
|
||||
socialMedia Json?
|
||||
age Int?
|
||||
heightCm Float?
|
||||
phone String? @unique
|
||||
isAdmin Boolean @default(false)
|
||||
tokenVersion Int @default(0)
|
||||
availability Json?
|
||||
priorities String?
|
||||
exclusions String?
|
||||
developMuscles String[] @default([])
|
||||
canDoMuscles String[] @default([])
|
||||
difficultMuscles String[] @default([])
|
||||
avoidMuscles String[] @default([])
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
memberships GymMembership[]
|
||||
plans TrainingPlan[]
|
||||
createdPlans TrainingPlan[] @relation("PlanCreator")
|
||||
weightEntries BodyMeasurement[]
|
||||
memberships GymMembership[]
|
||||
plans TrainingPlan[]
|
||||
createdPlans TrainingPlan[] @relation("PlanCreator")
|
||||
weightEntries BodyMeasurement[]
|
||||
circumferenceEntries CircumferenceMeasurement[]
|
||||
coachingsAsTrainer Coaching[] @relation("CoachingTrainer")
|
||||
coachingsAsUser Coaching[] @relation("CoachingUser")
|
||||
commentsAsAuthor Comment[] @relation("CommentAuthor")
|
||||
commentsAsTarget Comment[] @relation("CommentTarget")
|
||||
messagesAsSender Message[] @relation("MessageSender")
|
||||
conversationReads ConversationRead[]
|
||||
activityLogs ActivityLog[] @relation("ActivityLogActor")
|
||||
gymRatings GymRating[]
|
||||
gymClaims GymClaim[]
|
||||
claimsDecided GymClaim[] @relation("ClaimDecider")
|
||||
gymInvitations GymInvitation[]
|
||||
gymInvitationsSent GymInvitation[] @relation("GymInviteSender")
|
||||
coachingsAsTrainer Coaching[] @relation("CoachingTrainer")
|
||||
coachingsAsUser Coaching[] @relation("CoachingUser")
|
||||
commentsAsAuthor Comment[] @relation("CommentAuthor")
|
||||
commentsAsTarget Comment[] @relation("CommentTarget")
|
||||
messagesAsSender Message[] @relation("MessageSender")
|
||||
conversationReads ConversationRead[]
|
||||
activityLogs ActivityLog[] @relation("ActivityLogActor")
|
||||
gymRatings GymRating[]
|
||||
gymClaims GymClaim[]
|
||||
claimsDecided GymClaim[] @relation("ClaimDecider")
|
||||
gymInvitations GymInvitation[]
|
||||
gymInvitationsSent GymInvitation[] @relation("GymInviteSender")
|
||||
}
|
||||
|
||||
/// Audit trail of user actions (app + trainer level). Best-effort writes,
|
||||
@@ -147,16 +147,16 @@ model ActivityLog {
|
||||
/// Trainer ↔ trainee relation. Created as PENDING (invitation), becomes ACTIVE
|
||||
/// after the invited party accepts. Invitations expire after 7 days.
|
||||
model Coaching {
|
||||
id String @id @default(cuid())
|
||||
trainerId String
|
||||
userId String
|
||||
gymId String?
|
||||
status CoachingStatus @default(PENDING)
|
||||
note String?
|
||||
invitedBy String
|
||||
invitedAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
id String @id @default(cuid())
|
||||
trainerId String
|
||||
userId String
|
||||
gymId String?
|
||||
status CoachingStatus @default(PENDING)
|
||||
note String?
|
||||
invitedBy String
|
||||
invitedAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
trainer User @relation("CoachingTrainer", fields: [trainerId], references: [id], onDelete: Cascade)
|
||||
user User @relation("CoachingUser", fields: [userId], references: [id], onDelete: Cascade)
|
||||
@@ -216,26 +216,27 @@ model ConversationRead {
|
||||
}
|
||||
|
||||
model Gym {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
location String?
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
location String?
|
||||
availability Json?
|
||||
capacity Int?
|
||||
capacity Int?
|
||||
/// Existing rows default to REAL; VIRTUAL gyms are created by users.
|
||||
kind GymKind @default(REAL)
|
||||
kind GymKind @default(REAL)
|
||||
/// Only meaningful for VIRTUAL gyms (hidden from the public list).
|
||||
isPrivate Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
isPrivate Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
memberships GymMembership[]
|
||||
memberships GymMembership[]
|
||||
customExercises Exercise[]
|
||||
equipment GymEquipment[]
|
||||
exceptions GymException[]
|
||||
ratings GymRating[]
|
||||
claims GymClaim[]
|
||||
invitations GymInvitation[]
|
||||
photos GymPhoto[]
|
||||
equipment GymEquipment[]
|
||||
exceptions GymException[]
|
||||
ratings GymRating[]
|
||||
claims GymClaim[]
|
||||
invitations GymInvitation[]
|
||||
photos GymPhoto[]
|
||||
plans TrainingPlan[]
|
||||
}
|
||||
|
||||
/// Zdjęcie w galerii siłowni REAL. `order` = kolejność; okładka = najmniejsze `order` (tie → najstarsze `createdAt`).
|
||||
@@ -262,7 +263,7 @@ model GymRating {
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
gym Gym @relation(fields: [gymId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([gymId, userId])
|
||||
@@index([gymId])
|
||||
@@ -271,33 +272,33 @@ model GymRating {
|
||||
/// A claim: verification of an existing virtual gym (gymId set) or a request for a
|
||||
/// new real gym (gymId null, gym data carried in the claim).
|
||||
model GymClaim {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
/// null = claim for a NEW real gym (data below); set = verification of that virtual gym.
|
||||
gymId String?
|
||||
userId String
|
||||
gymId String?
|
||||
userId String
|
||||
/// Gym data — only for claims with gymId = null:
|
||||
gymName String?
|
||||
gymLocation String?
|
||||
gymName String?
|
||||
gymLocation String?
|
||||
gymAvailability Json?
|
||||
gymCapacity Int?
|
||||
gymCapacity Int?
|
||||
/// Applicant data / proof:
|
||||
description String
|
||||
companyName String?
|
||||
nip String?
|
||||
phone String?
|
||||
email String?
|
||||
description String
|
||||
companyName String?
|
||||
nip String?
|
||||
phone String?
|
||||
email String?
|
||||
/// Verification claims only: overrides gym.location on approval.
|
||||
address String?
|
||||
status ClaimStatus @default(PENDING)
|
||||
rejectReason String?
|
||||
decidedById String?
|
||||
decidedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
address String?
|
||||
status ClaimStatus @default(PENDING)
|
||||
rejectReason String?
|
||||
decidedById String?
|
||||
decidedAt DateTime?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
gym Gym? @relation(fields: [gymId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
decidedBy User? @relation("ClaimDecider", fields: [decidedById], references: [id], onDelete: SetNull)
|
||||
gym Gym? @relation(fields: [gymId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
decidedBy User? @relation("ClaimDecider", fields: [decidedById], references: [id], onDelete: SetNull)
|
||||
documents GymClaimDocument[]
|
||||
|
||||
@@index([gymId, status])
|
||||
@@ -320,14 +321,14 @@ model GymClaimDocument {
|
||||
|
||||
/// Invitation to a PRIVATE virtual gym (owner invites a specific user, 7-day TTL).
|
||||
model GymInvitation {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
gymId String
|
||||
userId String
|
||||
invitedById String
|
||||
status GymInvitationStatus @default(PENDING)
|
||||
invitedAt DateTime @default(now())
|
||||
invitedAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
createdAt DateTime @default(now())
|
||||
|
||||
gym Gym @relation(fields: [gymId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
@@ -342,10 +343,10 @@ model GymInvitation {
|
||||
/// Gym ↔ equipment instance: how many units of a catalog item a gym has
|
||||
/// (e.g. two pairs of dumbbells).
|
||||
model GymEquipment {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
gymId String
|
||||
equipmentId String
|
||||
quantity Int @default(1)
|
||||
quantity Int @default(1)
|
||||
|
||||
gym Gym @relation(fields: [gymId], references: [id], onDelete: Cascade)
|
||||
equipment Equipment @relation(fields: [equipmentId], references: [id], onDelete: Cascade)
|
||||
@@ -381,7 +382,7 @@ model FocusArea {
|
||||
}
|
||||
|
||||
model GymMembership {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
gymId String
|
||||
roles GymRole[] @default([MEMBER])
|
||||
@@ -431,8 +432,8 @@ model Equipment {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
exercises Exercise[]
|
||||
gyms GymEquipment[]
|
||||
exercises Exercise[]
|
||||
gyms GymEquipment[]
|
||||
}
|
||||
|
||||
model Exercise {
|
||||
@@ -464,7 +465,7 @@ model Exercise {
|
||||
gym Gym? @relation(fields: [gymId], references: [id], onDelete: SetNull)
|
||||
equipment Equipment[]
|
||||
|
||||
planExercises PlanExercise[]
|
||||
planExercises PlanExercise[]
|
||||
sessionExercises SessionExercise[]
|
||||
|
||||
@@index([source])
|
||||
@@ -478,20 +479,26 @@ model TrainingPlan {
|
||||
status PlanStatus @default(DRAFT)
|
||||
weeksCount Int
|
||||
startDate DateTime?
|
||||
/// Informacyjna — siłownia, w której realizowany jest plan (bez wpływu na scheduler).
|
||||
gymId String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
creator User? @relation("PlanCreator", fields: [creatorId], references: [id], onDelete: SetNull)
|
||||
gym Gym? @relation(fields: [gymId], references: [id], onDelete: SetNull)
|
||||
weeks PlanWeek[]
|
||||
|
||||
@@index([userId, status])
|
||||
@@index([gymId])
|
||||
}
|
||||
|
||||
model PlanWeek {
|
||||
id String @id @default(cuid())
|
||||
planId String
|
||||
index Int
|
||||
id String @id @default(cuid())
|
||||
planId String
|
||||
index Int
|
||||
/// Opcjonalny alias tygodnia (np. „Deload").
|
||||
customName String?
|
||||
|
||||
plan TrainingPlan @relation(fields: [planId], references: [id], onDelete: Cascade)
|
||||
days PlanDay[]
|
||||
@@ -500,15 +507,15 @@ model PlanWeek {
|
||||
}
|
||||
|
||||
model PlanDay {
|
||||
id String @id @default(cuid())
|
||||
id String @id @default(cuid())
|
||||
weekId String
|
||||
dayOfWeek Int
|
||||
date DateTime?
|
||||
status DayStatus @default(PLANNED)
|
||||
status DayStatus @default(PLANNED)
|
||||
completedAt DateTime?
|
||||
skippedAt DateTime?
|
||||
|
||||
week PlanWeek @relation(fields: [weekId], references: [id], onDelete: Cascade)
|
||||
week PlanWeek @relation(fields: [weekId], references: [id], onDelete: Cascade)
|
||||
moveLog DayMove[]
|
||||
exercises PlanExercise[]
|
||||
sessions TrainingSession[]
|
||||
@@ -542,19 +549,19 @@ model PlanExercise {
|
||||
}
|
||||
|
||||
model PlanSet {
|
||||
id String @id @default(cuid())
|
||||
exerciseId String
|
||||
index Int
|
||||
reps Int?
|
||||
loadKg Float?
|
||||
restSec Int?
|
||||
rir Int?
|
||||
difficulty Int?
|
||||
cardioBpm Int?
|
||||
timeSec Int?
|
||||
speed Float?
|
||||
id String @id @default(cuid())
|
||||
exerciseId String
|
||||
index Int
|
||||
reps Int?
|
||||
loadKg Float?
|
||||
restSec Int?
|
||||
rir Int?
|
||||
difficulty Int?
|
||||
cardioBpm Int?
|
||||
timeSec Int?
|
||||
speed Float?
|
||||
|
||||
exercise PlanExercise @relation(fields: [exerciseId], references: [id], onDelete: Cascade)
|
||||
exercise PlanExercise @relation(fields: [exerciseId], references: [id], onDelete: Cascade)
|
||||
sessionSets SessionSet[]
|
||||
|
||||
@@unique([exerciseId, index])
|
||||
@@ -567,9 +574,9 @@ model TrainingSession {
|
||||
startedAt DateTime @default(now())
|
||||
endedAt DateTime?
|
||||
|
||||
day PlanDay @relation(fields: [dayId], references: [id], onDelete: Cascade)
|
||||
exercises SessionExercise[]
|
||||
messagesAsSession Message[] @relation("MessageSession")
|
||||
day PlanDay @relation(fields: [dayId], references: [id], onDelete: Cascade)
|
||||
exercises SessionExercise[]
|
||||
messagesAsSession Message[] @relation("MessageSession")
|
||||
|
||||
@@index([dayId, status])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user