Add lessons Phase 3: enrollments with capacity and time conflict checks
Links members to schedule slots via enrollments. Enforces max_students capacity on slots and prevents members from double-booking the same day/time. Supports status transitions and filtering. 11 new tests (51 total lessons tests).
This commit is contained in:
19
packages/backend/src/db/migrations/0030_enrollments.sql
Normal file
19
packages/backend/src/db/migrations/0030_enrollments.sql
Normal file
@@ -0,0 +1,19 @@
|
||||
-- Phase 3: Enrollments — member enrollment in a schedule slot
|
||||
|
||||
CREATE TYPE "enrollment_status" AS ENUM ('active', 'paused', 'cancelled', 'completed');
|
||||
|
||||
CREATE TABLE "enrollment" (
|
||||
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid(),
|
||||
"member_id" uuid NOT NULL REFERENCES "member"("id"),
|
||||
"account_id" uuid NOT NULL REFERENCES "account"("id"),
|
||||
"schedule_slot_id" uuid NOT NULL REFERENCES "schedule_slot"("id"),
|
||||
"instructor_id" uuid NOT NULL REFERENCES "instructor"("id"),
|
||||
"status" enrollment_status NOT NULL DEFAULT 'active',
|
||||
"start_date" date NOT NULL,
|
||||
"end_date" date,
|
||||
"monthly_rate" numeric(10,2),
|
||||
"makeup_credits" integer NOT NULL DEFAULT 0,
|
||||
"notes" text,
|
||||
"created_at" timestamptz NOT NULL DEFAULT now(),
|
||||
"updated_at" timestamptz NOT NULL DEFAULT now()
|
||||
);
|
||||
@@ -211,6 +211,13 @@
|
||||
"when": 1774890000000,
|
||||
"tag": "0029_schedule_slots",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 30,
|
||||
"version": "7",
|
||||
"when": 1774900000000,
|
||||
"tag": "0030_enrollments",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user