mirror of
https://github.com/block/buzz.git
synced 2026-10-29 21:41:33 +00:00
Reject client-authored wakes, authenticate relay signatures before authority lookup, and preserve the storage-level FTS exclusion on brownfield databases. Co-authored-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <loganj@squareup.com> Signed-off-by: Larry <8cf5a83f590ec0955b11647d1c88f796a98e088c30a492c58e0e46c3026ae7a4@buzz.block.builderlab.xyz> Signed-off-by: Logan Johnson <loganj@squareup.com>
33 lines
1.3 KiB
SQL
33 lines
1.3 KiB
SQL
-- Kind:44620 is a durable, recipient-gated workflow mention wake. Its canonical
|
|
-- content is empty, but keep the storage-level full-text-search backstop aligned
|
|
-- with every persistent P_GATED_KINDS member, including on brownfield databases
|
|
-- that retain the legacy negative skip-set.
|
|
--
|
|
-- Preserve the database's existing search policy for every other kind. As with
|
|
-- 0014 and 0033, replacing this generated column rewrites the events table and
|
|
-- rebuilds the GIN index under an ACCESS EXCLUSIVE lock.
|
|
DO $$
|
|
DECLARE
|
|
existing_expression TEXT;
|
|
BEGIN
|
|
SELECT pg_get_expr(d.adbin, d.adrelid)
|
|
INTO existing_expression
|
|
FROM pg_attrdef d
|
|
JOIN pg_attribute a
|
|
ON a.attrelid = d.adrelid
|
|
AND a.attnum = d.adnum
|
|
WHERE d.adrelid = 'events'::regclass
|
|
AND a.attname = 'search_tsv';
|
|
|
|
IF existing_expression IS NULL THEN
|
|
RAISE EXCEPTION 'events.search_tsv generated expression not found';
|
|
END IF;
|
|
|
|
ALTER TABLE events DROP COLUMN search_tsv;
|
|
EXECUTE format(
|
|
'ALTER TABLE events ADD COLUMN search_tsv TSVECTOR GENERATED ALWAYS AS (CASE WHEN kind = 44620 THEN NULL::tsvector ELSE (%s) END) STORED',
|
|
existing_expression
|
|
);
|
|
CREATE INDEX idx_events_search_tsv ON events USING GIN (search_tsv);
|
|
END $$;
|