-- ── Bans + timeouts (one restriction row per member) ────────────────────────── -- Ban = connection block, enforced at the NIP-42 auth seam -- ("blocked: you are banned from this community") + join/ingest surfaces. -- Timeout = write-block only ("restricted: you are timed out until "). -- A row may be ban-only, timeout-only, or both over its lifetime. CREATE TABLE community_bans ( community_id UUID NOT NULL REFERENCES communities(id), pubkey BYTEA NOT NULL CHECK (length(pubkey) = 32), banned BOOLEAN NOT NULL DEFAULT false, -- NULL + banned=true ⇒ permanent. ban_expires_at TIMESTAMPTZ, ban_reason TEXT, -- Write-block until this timestamp; NULL or past ⇒ not timed out. muted_until TIMESTAMPTZ, mute_reason TEXT, -- Moderator who last modified this row. actor_pubkey BYTEA NOT NULL CHECK (length(actor_pubkey) = 32), created_at TIMESTAMPTZ NOT NULL DEFAULT now(), updated_at TIMESTAMPTZ NOT NULL DEFAULT now(), PRIMARY KEY (community_id, pubkey) );