-- Migration to move voice signaling and participants to the database
ALTER TABLE voice_sessions ADD COLUMN peer_id VARCHAR(16) NOT NULL;
ALTER TABLE voice_sessions ADD COLUMN name VARCHAR(50);
-- Reset voice_sessions as we changed schema
TRUNCATE TABLE voice_sessions;

CREATE TABLE IF NOT EXISTS voice_signals (
    id INT AUTO_INCREMENT PRIMARY KEY,
    room_id VARCHAR(50) NOT NULL,
    from_peer_id VARCHAR(16) NOT NULL,
    to_peer_id VARCHAR(16) NOT NULL,
    data TEXT NOT NULL,
    created_at BIGINT NOT NULL,
    INDEX (to_peer_id),
    INDEX (room_id),
    INDEX (created_at)
);
