diff --git a/migrations/20241113-make-post-searching-same-as-comment-searching.sql b/migrations/20241113-make-post-searching-same-as-comment-searching.sql new file mode 100644 index 000000000..0c436ad7e --- /dev/null +++ b/migrations/20241113-make-post-searching-same-as-comment-searching.sql @@ -0,0 +1,9 @@ +alter table posts add column title_ts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (title)::text)) STORED; +alter table posts add column body_ts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (body)::text)) STORED; +alter table posts add column url_ts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (url)::text)) STORED; +alter table posts add column embed_ts tsvector GENERATED ALWAYS AS (to_tsvector('simple'::regconfig, (embed)::text)) STORED; + +CREATE INDEX posts_title_ts_idx ON public.posts USING gin (title_ts); +CREATE INDEX posts_body_ts_idx ON public.posts USING gin (body_ts); +CREATE INDEX posts_url_ts_idx ON public.posts USING gin (url_ts); +CREATE INDEX posts_embed_ts_idx ON public.posts USING gin (embed_ts); \ No newline at end of file