Set logging is now a united. Sporadic set table removed.

This commit is contained in:
AG
2025-12-05 08:55:59 +02:00
parent a632de65ea
commit 41d1d0f16a
19 changed files with 1129 additions and 1232 deletions

Binary file not shown.

View File

@@ -0,0 +1,54 @@
/*
Warnings:
- You are about to drop the `SporadicSet` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropIndex
DROP INDEX "SporadicSet_userId_timestamp_idx";
-- DropTable
PRAGMA foreign_keys=off;
DROP TABLE "SporadicSet";
PRAGMA foreign_keys=on;
-- RedefineTables
PRAGMA defer_foreign_keys=ON;
PRAGMA foreign_keys=OFF;
CREATE TABLE "new_WorkoutSession" (
"id" TEXT NOT NULL PRIMARY KEY,
"userId" TEXT NOT NULL,
"startTime" DATETIME NOT NULL,
"endTime" DATETIME,
"userBodyWeight" REAL,
"note" TEXT,
"planId" TEXT,
"planName" TEXT,
"type" TEXT NOT NULL DEFAULT 'STANDARD',
CONSTRAINT "WorkoutSession_userId_fkey" FOREIGN KEY ("userId") REFERENCES "User" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);
INSERT INTO "new_WorkoutSession" ("endTime", "id", "note", "planId", "planName", "startTime", "userBodyWeight", "userId") SELECT "endTime", "id", "note", "planId", "planName", "startTime", "userBodyWeight", "userId" FROM "WorkoutSession";
DROP TABLE "WorkoutSession";
ALTER TABLE "new_WorkoutSession" RENAME TO "WorkoutSession";
CREATE TABLE "new_WorkoutSet" (
"id" TEXT NOT NULL PRIMARY KEY,
"sessionId" TEXT NOT NULL,
"exerciseId" TEXT NOT NULL,
"order" INTEGER NOT NULL,
"weight" REAL,
"reps" INTEGER,
"distanceMeters" REAL,
"durationSeconds" INTEGER,
"height" REAL,
"bodyWeightPercentage" REAL,
"completed" BOOLEAN NOT NULL DEFAULT true,
"side" TEXT,
"timestamp" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "WorkoutSet_sessionId_fkey" FOREIGN KEY ("sessionId") REFERENCES "WorkoutSession" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT "WorkoutSet_exerciseId_fkey" FOREIGN KEY ("exerciseId") REFERENCES "Exercise" ("id") ON DELETE RESTRICT ON UPDATE CASCADE
);
INSERT INTO "new_WorkoutSet" ("completed", "distanceMeters", "durationSeconds", "exerciseId", "id", "order", "reps", "sessionId", "side", "weight") SELECT "completed", "distanceMeters", "durationSeconds", "exerciseId", "id", "order", "reps", "sessionId", "side", "weight" FROM "WorkoutSet";
DROP TABLE "WorkoutSet";
ALTER TABLE "new_WorkoutSet" RENAME TO "WorkoutSet";
PRAGMA foreign_keys=ON;
PRAGMA defer_foreign_keys=OFF;

View File

@@ -25,7 +25,6 @@ model User {
exercises Exercise[]
plans WorkoutPlan[]
weightRecords BodyWeightRecord[]
sporadicSets SporadicSet[]
}
model BodyWeightRecord {
@@ -61,7 +60,6 @@ model Exercise {
isUnilateral Boolean @default(false)
sets WorkoutSet[]
sporadicSets SporadicSet[]
}
model WorkoutSession {
@@ -74,6 +72,7 @@ model WorkoutSession {
note String?
planId String?
planName String?
type String @default("STANDARD") // STANDARD, QUICK_LOG
sets WorkoutSet[]
}
@@ -90,8 +89,11 @@ model WorkoutSet {
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 {
@@ -105,23 +107,3 @@ model WorkoutPlan {
updatedAt DateTime @updatedAt
}
model SporadicSet {
id String @id @default(uuid())
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
exerciseId String
exercise Exercise @relation(fields: [exerciseId], references: [id])
weight Float?
reps Int?
distanceMeters Float?
durationSeconds Int?
height Float?
bodyWeightPercentage Float?
side String? // LEFT, RIGHT, or null for bilateral
timestamp DateTime @default(now())
note String?
@@index([userId, timestamp])
}