-- Add schedule_type to support different scheduling methods
ALTER TABLE maintenance_schedules
  ADD COLUMN schedule_type VARCHAR(20) NOT NULL DEFAULT 'interval'
    CHECK (schedule_type IN ('interval', 'fixed_date', 'time_since_last'));

-- Add fixed_due_date for fixed date schedules
ALTER TABLE maintenance_schedules
  ADD COLUMN fixed_due_date DATE;

-- Add reminder columns for progressive notifications
ALTER TABLE maintenance_schedules
  ADD COLUMN reminder_days_1 INTEGER
    CHECK (reminder_days_1 IN (1, 7, 14, 30, 60));

ALTER TABLE maintenance_schedules
  ADD COLUMN reminder_days_2 INTEGER
    CHECK (reminder_days_2 IN (1, 7, 14, 30, 60));

ALTER TABLE maintenance_schedules
  ADD COLUMN reminder_days_3 INTEGER
    CHECK (reminder_days_3 IN (1, 7, 14, 30, 60));

-- Index for filtering by schedule type
CREATE INDEX idx_maintenance_schedules_schedule_type ON maintenance_schedules(schedule_type);
