-- ── Channels ────────────────────────────────────────────────────────────────── -- Conformance: "Channels and channel membership". `community_id` immutable. -- Channel UUIDs stay valid wire identifiers, but they are NOT globally unique: -- the PK is `(community_id, id)`, so the same UUID may legitimately exist in two -- communities (conformance lists "same channel UUID collision in two -- communities" as a required isolation test). Handlers always carry `ctx`, so -- `(ctx.community, h)` names exactly one channel; a client-supplied `h` can -- never reach another community's channel. CREATE TABLE channels ( id UUID NOT NULL DEFAULT gen_random_uuid(), community_id UUID NOT NULL REFERENCES communities(id), name VARCHAR(255) NOT NULL, channel_type channel_type NOT NULL DEFAULT 'stream', visibility channel_visibility NOT NULL DEFAULT 'open', description TEXT, canvas TEXT, created_by BYTEA NOT NULL, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), archived_at TIMESTAMPTZ, deleted_at TIMESTAMPTZ, nip29_group_id VARCHAR(255), topic_required BOOLEAN NOT NULL DEFAULT FALSE, max_members INT, topic TEXT, topic_set_by BYTEA, topic_set_at TIMESTAMPTZ, purpose TEXT, purpose_set_by BYTEA, purpose_set_at TIMESTAMPTZ, participant_hash BYTEA, ttl_seconds INT, ttl_deadline TIMESTAMPTZ, -- Labels, published as ["t",