-- T0346: Create Bitrate Adaptation Database Model
-- Migration pour créer la table bitrate_adaptation_logs

CREATE TABLE bitrate_adaptation_logs (
    id BIGSERIAL PRIMARY KEY,
    track_id BIGINT NOT NULL REFERENCES tracks(id) ON DELETE CASCADE,
    user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
    old_bitrate INTEGER NOT NULL,
    new_bitrate INTEGER NOT NULL,
    reason VARCHAR(50) NOT NULL,
    network_bandwidth INTEGER,
    created_at TIMESTAMP NOT NULL DEFAULT NOW()
);

CREATE INDEX idx_bitrate_adaptation_track_id ON bitrate_adaptation_logs(track_id);
CREATE INDEX idx_bitrate_adaptation_user_id ON bitrate_adaptation_logs(user_id);
CREATE INDEX idx_bitrate_adaptation_created_at ON bitrate_adaptation_logs(created_at);

