-- Migration: Add channel permissions and user theme preference
CREATE TABLE IF NOT EXISTS channel_permissions (
    channel_id INT NOT NULL,
    role_id INT NOT NULL,
    allow_permissions INT DEFAULT 0,
    deny_permissions INT DEFAULT 0,
    PRIMARY KEY (channel_id, role_id),
    FOREIGN KEY (channel_id) REFERENCES channels(id) ON DELETE CASCADE,
    FOREIGN KEY (role_id) REFERENCES roles(id) ON DELETE CASCADE
);

ALTER TABLE users ADD COLUMN IF NOT EXISTS theme VARCHAR(20) DEFAULT 'dark';
