mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
Signed-off-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co> Co-authored-by: npub12gtutshhh76rx0jx697f32f9tffd4hhp3hx58fp4x6u4uemkm7sqf8f757 <5217c5c2f7bfb4333e46d17c98a9255a52dadee18dcd43a43536b95e6776dfa0@sprout-oss.stage.blox.sqprod.co>
24 lines
1.0 KiB
SQL
24 lines
1.0 KiB
SQL
-- Give new, empty installations the positive FTS allowlist without rewriting
|
|
-- populated databases during relay startup. Existing installations keep their
|
|
-- current search_tsv expression until an operator runs the sized out-of-band
|
|
-- maintenance script in scripts/maintenance/nip_rs_search_allowlist.sql.
|
|
--
|
|
-- Serialize the emptiness check with event writers. Reads remain available on
|
|
-- populated databases; an actually empty table upgrades briefly to ACCESS
|
|
-- EXCLUSIVE for the generated-column replacement and index build.
|
|
LOCK TABLE events IN SHARE ROW EXCLUSIVE MODE;
|
|
|
|
DO $$
|
|
BEGIN
|
|
IF NOT EXISTS (SELECT 1 FROM events LIMIT 1) THEN
|
|
ALTER TABLE events DROP COLUMN search_tsv;
|
|
ALTER TABLE events ADD COLUMN search_tsv TSVECTOR GENERATED ALWAYS AS (
|
|
CASE WHEN kind IN (0, 9, 40002, 45001, 45003)
|
|
THEN to_tsvector('simple', content)
|
|
ELSE NULL::tsvector
|
|
END
|
|
) STORED;
|
|
CREATE INDEX idx_events_search_tsv ON events USING GIN (search_tsv);
|
|
END IF;
|
|
END $$;
|