added standing orders in courses

This commit is contained in:
Rajpreet0 2026-06-27 16:50:10 +02:00
parent bb1937a452
commit 63e6e4dc5c
12 changed files with 600 additions and 100 deletions

View file

@ -0,0 +1,17 @@
-- Migration: add_standing_order_instances
-- Adds endDate, weekdayTimings, and parentCourseId (self-relation) to Course
ALTER TABLE "Course"
ADD COLUMN "weekdayTimings" JSONB,
ADD COLUMN "endDate" TIMESTAMP(3),
ADD COLUMN "parentCourseId" TEXT;
ALTER TABLE "Course"
ADD CONSTRAINT "Course_parentCourseId_fkey"
FOREIGN KEY ("parentCourseId")
REFERENCES "Course"("id")
ON DELETE CASCADE
ON UPDATE CASCADE;
CREATE INDEX "Course_parentCourseId_idx" ON "Course"("parentCourseId");
CREATE INDEX "Course_parentCourseId_date_idx" ON "Course"("parentCourseId", "date");

View file

@ -125,6 +125,11 @@ model Course {
isStandingOrder Boolean @default(false)
frequency String? // daily, weekly, biweekly, monthly, custom
weekdays String[] // For custom frequency
weekdayTimings Json? // { "monday": { "timeFrom": "08:00", "timeTo": "09:00" }, ... }
endDate DateTime? // Required when isStandingOrder = true
parentCourseId String? // Null on template; set on every child instance
parentCourse Course? @relation("StandingOrderInstances", fields: [parentCourseId], references: [id], onDelete: Cascade)
children Course[] @relation("StandingOrderInstances")
status String @default("draft") // draft, published
createdBy String // Manager ID who created the course
businessId String?
@ -138,6 +143,8 @@ model Course {
@@index([date])
@@index([status])
@@index([businessId])
@@index([parentCourseId])
@@index([parentCourseId, date])
}
model Room {