CREATE TABLE IF NOT EXISTS calendar_events (
  id INT AUTO_INCREMENT PRIMARY KEY,
  club_id INT NOT NULL,
  event_type VARCHAR(32) NOT NULL DEFAULT 'club_event',
  status VARCHAR(32) NOT NULL DEFAULT 'planning',
  title VARCHAR(255) NOT NULL,
  description TEXT NULL,
  location VARCHAR(255) NULL,
  start_date DATE NOT NULL,
  end_date DATE NOT NULL,
  registration_deadline DATE NULL,
  organizer_user_id INT NULL,
  category VARCHAR(64) NULL,
  notes TEXT NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  KEY idx_calendar_events_club_start (club_id, start_date),
  KEY idx_calendar_events_club_status (club_id, status),
  KEY idx_calendar_events_club_event_type (club_id, event_type),
  CONSTRAINT fk_calendar_events_club
    FOREIGN KEY (club_id) REFERENCES clubs(id)
    ON DELETE CASCADE
);
