-- ── Subscriptions ───────────────────────────────────────────────────────────── -- Conformance: "Mesh, agents, ACP/MCP, and CLI" (persisted subscriptions). CREATE TABLE subscriptions ( community_id UUID NOT NULL REFERENCES communities(id), id VARCHAR(255) NOT NULL, owner_pubkey BYTEA NOT NULL, filter_kinds JSONB, filter_authors JSONB, filter_channel_ids JSONB, filter_since TIMESTAMPTZ, filter_until TIMESTAMPTZ, delivery_method delivery_method NOT NULL DEFAULT 'webhook', delivery_url TEXT, status subscription_status NOT NULL DEFAULT 'active', pause_reason pause_reason, delivered_count BIGINT NOT NULL DEFAULT 0, error_count BIGINT NOT NULL DEFAULT 0, created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(), PRIMARY KEY (community_id, id), FOREIGN KEY (community_id, owner_pubkey) REFERENCES users (community_id, pubkey) );