-- 014_track_calendar.sql — schema for F1-style active track scheduling.

CREATE TABLE IF NOT EXISTS track_calendar (
    id SERIAL PRIMARY KEY,
    track_id TEXT NOT NULL REFERENCES tracks(id) ON DELETE CASCADE,
    start_at TIMESTAMP WITH TIME ZONE NOT NULL,
    end_at TIMESTAMP WITH TIME ZONE NOT NULL,
    CHECK (start_at < end_at)
);

CREATE INDEX IF NOT EXISTS track_calendar_dates_idx ON track_calendar (start_at, end_at);
