CREATE TABLE IF NOT EXISTS guild_config (
    guild_id INTEGER PRIMARY KEY,
    mod_channel_id INTEGER,
    immune_role_id INTEGER,
    ban_reason TEXT NOT NULL DEFAULT 'Posting in a restricted channel'
);

CREATE TABLE IF NOT EXISTS watched_channels (
    guild_id INTEGER NOT NULL,
    channel_id INTEGER NOT NULL,
    PRIMARY KEY (guild_id, channel_id),
    FOREIGN KEY (guild_id) REFERENCES guild_config(guild_id)
);

CREATE TABLE IF NOT EXISTS ban_log (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    guild_id INTEGER NOT NULL,
    user_id INTEGER NOT NULL,
    channel_id INTEGER NOT NULL,
    message_snippet TEXT,
    banned_at TEXT NOT NULL DEFAULT (datetime('now'))
);
