Files
lunarfront-app/packages/backend/src/db/migrations/0037_rate_cycles.sql
Ryan Moon 5ad27bc196 Add lessons module, rate cycles, EC2 deploy scripts, and help content
- Lessons module: lesson types, instructors, schedule slots, enrollments,
  sessions (list + week grid view), lesson plans, grading scales, templates
- Rate cycles: replace monthly_rate with billing_interval + billing_unit on
  enrollments; add weekly/monthly/quarterly rate presets to lesson types and
  schedule slots with auto-fill on enrollment form
- Member detail page: tabbed layout for details, identity documents, enrollments
- Sessions week view: custom 7-column grid replacing react-big-calendar
- Music store seed: instructors, lesson types, slots, enrollments, sessions,
  grading scale, lesson plan template
- Scrollbar styling: themed to match sidebar/app palette
- deploy/: EC2 setup and redeploy scripts, nginx config, systemd service
- Help: add Lessons category (overview, types, instructors, slots, enrollments,
  sessions, plans/grading); collapsible sidebar with independent scroll;
  remove POS/accounting references from docs
2026-03-30 18:52:57 -05:00

29 lines
1.4 KiB
SQL

-- Rate cycles: per-instructor rates on schedule_slot, generic billing terms on enrollment,
-- replace base_rate_monthly on lesson_type with weekly/monthly/quarterly presets
CREATE TYPE billing_unit AS ENUM ('day', 'week', 'month', 'quarter', 'year');
-- lesson_type: replace base_rate_monthly varchar with three numeric rate columns
ALTER TABLE lesson_type ADD COLUMN rate_weekly numeric(10,2);
ALTER TABLE lesson_type ADD COLUMN rate_monthly numeric(10,2);
ALTER TABLE lesson_type ADD COLUMN rate_quarterly numeric(10,2);
UPDATE lesson_type
SET rate_monthly = base_rate_monthly::numeric
WHERE base_rate_monthly IS NOT NULL
AND base_rate_monthly ~ '^\d+(\.\d+)?$';
ALTER TABLE lesson_type DROP COLUMN base_rate_monthly;
-- schedule_slot: add per-instructor preset rates
ALTER TABLE schedule_slot ADD COLUMN rate_weekly numeric(10,2);
ALTER TABLE schedule_slot ADD COLUMN rate_monthly numeric(10,2);
ALTER TABLE schedule_slot ADD COLUMN rate_quarterly numeric(10,2);
-- enrollment: replace monthly_rate with generic billing terms
ALTER TABLE enrollment ADD COLUMN rate numeric(10,2);
ALTER TABLE enrollment ADD COLUMN billing_interval integer;
ALTER TABLE enrollment ADD COLUMN billing_unit billing_unit;
UPDATE enrollment
SET rate = monthly_rate, billing_interval = 1, billing_unit = 'month'
WHERE monthly_rate IS NOT NULL;
ALTER TABLE enrollment DROP COLUMN monthly_rate;