CREATE TABLE IF NOT EXISTS league_overrides (
  id INT AUTO_INCREMENT PRIMARY KEY,
  league_id INT NOT NULL,
  spieler_id INT NOT NULL,
  reason VARCHAR(255) NULL,
  active TINYINT(1) NOT NULL DEFAULT 1,
  created_by INT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  CONSTRAINT fk_league_overrides_league
    FOREIGN KEY (league_id) REFERENCES leagues(id)
    ON DELETE CASCADE,
  CONSTRAINT fk_league_overrides_spieler
    FOREIGN KEY (spieler_id) REFERENCES Spieler(SpielerID)
    ON DELETE CASCADE
);

CREATE INDEX idx_league_overrides_league ON league_overrides (league_id);
CREATE INDEX idx_league_overrides_spieler ON league_overrides (spieler_id);
CREATE INDEX idx_league_overrides_active ON league_overrides (active);
