-- Add rules_role_id to channels and create rule_acceptances table
ALTER TABLE channels ADD COLUMN rules_role_id INT NULL;

CREATE TABLE IF NOT EXISTS rule_acceptances (
    id INT AUTO_INCREMENT PRIMARY KEY,
    user_id INT NOT NULL,
    channel_id INT NOT NULL,
    accepted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    UNIQUE KEY user_channel (user_id, channel_id),
    FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
    FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE CASCADE
);
