-- Records every mod_id eviction the worker performs (one wsid claiming a mod_id
-- previously held by another). Used by /api/sort to warn the user when their
-- input includes multiple wsids that declare the same mod_id (PZ silently
-- loads only one; the others' folders end up dead weight on the server).
CREATE TABLE IF NOT EXISTS mod_id_conflicts (
    mod_id          TEXT NOT NULL,
    evicting_wsid   TEXT NOT NULL,
    evicted_wsid    TEXT NOT NULL,
    recorded_at     TIMESTAMPTZ NOT NULL DEFAULT now(),
    PRIMARY KEY (mod_id, evicting_wsid, evicted_wsid)
);
CREATE INDEX IF NOT EXISTS mod_id_conflicts_evicted_idx  ON mod_id_conflicts (evicted_wsid);
CREATE INDEX IF NOT EXISTS mod_id_conflicts_evicting_idx ON mod_id_conflicts (evicting_wsid);
