pinakes/migrations/postgres/V2__fts_indexes.sql
NotAShelf 9e5eb41d39
nix: set up project-wide formatter
Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I4806c58aa0a17f504c9312723ad770166a6a6964
2026-03-22 23:58:28 +03:00

12 lines
603 B
SQL

ALTER TABLE media_items
ADD COLUMN IF NOT EXISTS search_vector tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('english', COALESCE(title, '')), 'A') || setweight(to_tsvector('english', COALESCE(artist, '')), 'B') || setweight(to_tsvector('english', COALESCE(album, '')), 'B') || setweight(to_tsvector('english', COALESCE(genre, '')), 'C') || setweight(
to_tsvector('english', COALESCE(description, '')),
'C'
) || setweight(
to_tsvector('english', COALESCE(file_name, '')),
'D'
)
) STORED;
CREATE INDEX IF NOT EXISTS idx_media_search ON media_items USING GIN (search_vector);