|
| 1 | +-- Enable pg_trgm for trigram indexes |
| 2 | +CREATE EXTENSION IF NOT EXISTS pg_trgm; |
| 3 | + |
| 4 | +-- Remove deprecated columns from projects |
| 5 | +ALTER TABLE ow_projects DROP COLUMN IF EXISTS tags; |
| 6 | +ALTER TABLE ow_projects DROP COLUMN IF EXISTS devenv; |
| 7 | + |
| 8 | +-- Projects: name/title/description |
| 9 | +CREATE INDEX IF NOT EXISTS idx_ow_projects_name_trgm |
| 10 | + ON ow_projects USING gin (name gin_trgm_ops); |
| 11 | +CREATE INDEX IF NOT EXISTS idx_ow_projects_title_trgm |
| 12 | + ON ow_projects USING gin (title gin_trgm_ops); |
| 13 | +CREATE INDEX IF NOT EXISTS idx_ow_projects_description_trgm |
| 14 | + ON ow_projects USING gin (description gin_trgm_ops); |
| 15 | + |
| 16 | +-- Posts: content |
| 17 | +CREATE INDEX IF NOT EXISTS idx_ow_posts_content_trgm |
| 18 | + ON ow_posts USING gin (content gin_trgm_ops); |
| 19 | + |
| 20 | +-- Project files: source (trgm), creator, create_time |
| 21 | +CREATE INDEX IF NOT EXISTS idx_ow_projects_file_source_tsv_simple |
| 22 | + ON ow_projects_file |
| 23 | + USING gin (to_tsvector('simple', left(COALESCE(source, ''), 200000))); |
| 24 | +CREATE INDEX IF NOT EXISTS idx_ow_projects_file_create_userid |
| 25 | + ON ow_projects_file (create_userid); |
| 26 | +CREATE INDEX IF NOT EXISTS idx_ow_projects_file_create_time |
| 27 | + ON ow_projects_file (create_time); |
| 28 | + |
| 29 | +-- Users: username/display_name/bio/motto/location/region |
| 30 | +CREATE INDEX IF NOT EXISTS idx_ow_users_username_trgm |
| 31 | + ON ow_users USING gin (username gin_trgm_ops); |
| 32 | +CREATE INDEX IF NOT EXISTS idx_ow_users_display_name_trgm |
| 33 | + ON ow_users USING gin (display_name gin_trgm_ops); |
| 34 | +CREATE INDEX IF NOT EXISTS idx_ow_users_bio_trgm |
| 35 | + ON ow_users USING gin (bio gin_trgm_ops); |
| 36 | +CREATE INDEX IF NOT EXISTS idx_ow_users_motto_trgm |
| 37 | + ON ow_users USING gin (motto gin_trgm_ops); |
| 38 | +CREATE INDEX IF NOT EXISTS idx_ow_users_location_trgm |
| 39 | + ON ow_users USING gin (location gin_trgm_ops); |
| 40 | +CREATE INDEX IF NOT EXISTS idx_ow_users_region_trgm |
| 41 | + ON ow_users USING gin (region gin_trgm_ops); |
0 commit comments