CREATE TABLE IF NOT EXISTS training_cancellations (
  id INT AUTO_INCREMENT PRIMARY KEY,
  club_id INT NOT NULL,
  start_date DATE NOT NULL,
  end_date DATE NOT NULL,
  date DATE NULL,
  reason VARCHAR(255) NULL,
  training_group_ids JSON NULL,
  created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  UNIQUE KEY uniq_training_cancellation_club_range (club_id, start_date, end_date),
  CONSTRAINT fk_training_cancellations_club
    FOREIGN KEY (club_id) REFERENCES clubs(id)
    ON DELETE CASCADE
);
