Skip to content

Commit

Permalink
chore(sql): add sql migration script to remove isSearchable
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneRifle committed Nov 16, 2020
1 parent eca5738 commit ac5c401
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/server/db_migrations/20201116_remove_isSearchable.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
-- This migration script removes Urls.isSearchable with a default
-- of true and changes the index to index unconditionally
-- sql statements in scripts/ should be run to update functions too
BEGIN TRANSACTION;

-- Set "isSearchable" in url_histories to be false
ALTER TABLE url_histories DROP COLUMN "isSearchable";
ALTER TABLE urls DROP COLUMN "isSearchable";


DROP INDEX IF EXISTS urls_weighted_search_idx;

-- Search will be run on a concatenation of vectors formed from short links and their
-- description. Descriptions are given a lower weight than short links as short link
-- words can be taken as the title and words there are likely to be more important than
-- those in their corresponding description.
-- Search queries will have to use this exact expresion to be able to utilize the index.
CREATE INDEX urls_weighted_search_idx ON urls USING gin ((setweight(to_tsvector(
'english', urls."shortUrl"), 'A') || setweight(to_tsvector('english',
urls."description"), 'B')));

COMMIT;

0 comments on commit ac5c401

Please sign in to comment.