feat: phase 3 — history endpoints (start, entries, complete)

This commit is contained in:
2026-03-26 03:56:46 +00:00
parent 4646c6ed1a
commit 2389376721
7 changed files with 181 additions and 7 deletions

View File

@@ -0,0 +1,12 @@
/*
Warnings:
- Added the required column `programId` to the `histories` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "histories" ADD COLUMN "completedAt" TIMESTAMP(3),
ADD COLUMN "programId" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "histories" ADD CONSTRAINT "histories_programId_fkey" FOREIGN KEY ("programId") REFERENCES "programs"("id") ON DELETE CASCADE ON UPDATE CASCADE;

View File

@@ -88,6 +88,7 @@ model Program {
exercises ProgramExercise[]
groups GroupProgram[]
histories History[]
@@map("programs")
}
@@ -111,12 +112,15 @@ model ProgramExercise {
// ─── History ─────────────────────────────────────────────────────────────────
model History {
id String @id @default(uuid())
date DateTime @default(now())
notes String?
id String @id @default(uuid())
date DateTime @default(now())
completedAt DateTime?
notes String?
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
programId String
program Program @relation(fields: [programId], references: [id], onDelete: Cascade)
entries HistoryEntry[]