-- 128_track_reposts.sql
-- v0.10.3 F203: Reposts (partage d'une track dans son profil)

CREATE TABLE IF NOT EXISTS public.track_reposts (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id UUID NOT NULL REFERENCES public.users(id) ON DELETE CASCADE,
    track_id UUID NOT NULL REFERENCES public.tracks(id) ON DELETE CASCADE,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    UNIQUE(user_id, track_id)
);

CREATE INDEX idx_track_reposts_user_id ON public.track_reposts(user_id);
CREATE INDEX idx_track_reposts_track_id ON public.track_reposts(track_id);
CREATE INDEX idx_track_reposts_created_at ON public.track_reposts(created_at DESC);
