-- Step 23: Recording plan archive/delete stabilization.
-- Run after step22_management_final_audit.sql.

ALTER TABLE active_recording_plans
  MODIFY status ENUM('Active','Ended','Paused','Archived') NOT NULL DEFAULT 'Active';

ALTER TABLE active_recording_plans
  ADD COLUMN archived_at DATETIME DEFAULT NULL,
  ADD COLUMN archived_by INT UNSIGNED DEFAULT NULL,
  ADD COLUMN archive_reason TEXT DEFAULT NULL,
  ADD KEY idx_active_plans_archived_at (archived_at),
  ADD CONSTRAINT fk_active_plans_archived_by
    FOREIGN KEY (archived_by) REFERENCES users(id)
    ON UPDATE CASCADE
    ON DELETE SET NULL;
