-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(sql): add sql migration script to remove isSearchable
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |