Skip to content

Commit fb74fd2

Browse files
committed
add search index
1 parent 25e38f3 commit fb74fd2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
defmodule Algora.Repo.Migrations.AddLinkedinMetaTextIndex do
2+
use Ecto.Migration
3+
4+
def up do
5+
execute "CREATE EXTENSION IF NOT EXISTS pg_trgm"
6+
# Drop old index that only covered 'experience' field
7+
execute "DROP INDEX IF EXISTS users_lower_idx"
8+
# Create new index covering entire linkedin_meta JSON
9+
execute "CREATE INDEX users_linkedin_meta_text_idx ON users USING gin(lower(linkedin_meta::text) gin_trgm_ops)"
10+
end
11+
12+
def down do
13+
execute "DROP INDEX IF EXISTS users_linkedin_meta_text_idx"
14+
# Recreate old index
15+
execute "CREATE INDEX users_lower_idx ON users USING gin(lower(linkedin_meta ->> 'experience') gin_trgm_ops) WHERE linkedin_meta ->> 'experience' IS NOT NULL"
16+
end
17+
end

0 commit comments

Comments
 (0)