-- 943_create_track_stems.sql
-- v0.10.7 F482: Stem sharing (wav, aiff, flac)

CREATE TABLE IF NOT EXISTS track_stems (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    track_id UUID NOT NULL REFERENCES tracks(id) ON DELETE CASCADE,
    name VARCHAR(100) NOT NULL,
    file_path VARCHAR(500) NOT NULL,
    format VARCHAR(10) NOT NULL,
    size_bytes BIGINT NOT NULL DEFAULT 0,
    created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
    CONSTRAINT uq_track_stems_track_name UNIQUE (track_id, name)
);

CREATE INDEX IF NOT EXISTS idx_track_stems_track_id ON track_stems(track_id);

COMMENT ON TABLE track_stems IS 'v0.10.7 F482: Individual stems per track (kick, snare, bass, etc.)';
