-- T0331: Create HLS Streaming Database Model
-- Create table hls_streams for HLS streaming support

-- Table hls_streams
CREATE TABLE IF NOT EXISTS hls_streams (
    id BIGSERIAL PRIMARY KEY,
    track_id BIGINT NOT NULL REFERENCES tracks(id) ON DELETE CASCADE,
    playlist_url VARCHAR(500) NOT NULL,
    segments_count INTEGER NOT NULL DEFAULT 0,
    bitrates JSONB NOT NULL DEFAULT '[]',
    status VARCHAR(20) NOT NULL DEFAULT 'pending',
    created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- Indexes for performance
CREATE INDEX IF NOT EXISTS idx_hls_streams_track_id ON hls_streams(track_id);
CREATE INDEX IF NOT EXISTS idx_hls_streams_status ON hls_streams(status);

