-- Migration: Füge liga_id zu mappools hinzu und richte Foreign Key ein
ALTER TABLE mappools ADD COLUMN liga_id INT NOT NULL AFTER season;
ALTER TABLE mappools ADD CONSTRAINT fk_mappools_liga FOREIGN KEY (liga_id) REFERENCES leagues(id);

-- Falls die Tabelle mappool_maps noch nicht existiert:
CREATE TABLE IF NOT EXISTS mappool_maps (
    mappool_id INT NOT NULL,
    map_id INT NOT NULL,
    PRIMARY KEY (mappool_id, map_id),
    FOREIGN KEY (mappool_id) REFERENCES mappools(id) ON DELETE CASCADE,
    FOREIGN KEY (map_id) REFERENCES maps(id) ON DELETE CASCADE
);
