-- Moderation tables: reports and bans.

CREATE TABLE IF NOT EXISTS reports (
    id                  INTEGER PRIMARY KEY AUTOINCREMENT,
    encrypted_report    BLOB NOT NULL,
    conversation_id     BLOB NOT NULL,
    reporter_identity   BLOB NOT NULL,
    created_at          INTEGER NOT NULL DEFAULT (strftime('%s', 'now'))
);

CREATE INDEX IF NOT EXISTS idx_reports_created ON reports(created_at);

CREATE TABLE IF NOT EXISTS bans (
    identity_key    BLOB PRIMARY KEY,
    reason          TEXT NOT NULL DEFAULT '',
    banned_at       INTEGER NOT NULL DEFAULT (strftime('%s', 'now')),
    expires_at      INTEGER NOT NULL DEFAULT 0
);

CREATE INDEX IF NOT EXISTS idx_bans_expires ON bans(expires_at);
