Skip to content

Commit f58b926

Browse files
committed
add gin indexes
1 parent 35a011f commit f58b926

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
defmodule Algora.Repo.Migrations.AddSearchOptimizationIndexes do
2+
use Ecto.Migration
3+
4+
def change do
5+
execute "CREATE EXTENSION IF NOT EXISTS pg_trgm", "DROP EXTENSION IF EXISTS pg_trgm"
6+
7+
create index(:users, ["lower(provider_login) gin_trgm_ops"],
8+
using: :gin,
9+
where: "provider_login IS NOT NULL"
10+
)
11+
12+
create index(:users, ["lower(bio) gin_trgm_ops"],
13+
using: :gin,
14+
where: "bio IS NOT NULL"
15+
)
16+
17+
create index(:users, ["lower(readme) gin_trgm_ops"],
18+
using: :gin,
19+
where: "readme IS NOT NULL"
20+
)
21+
22+
create index(:users, ["lower(internal_notes) gin_trgm_ops"],
23+
using: :gin,
24+
where: "internal_notes IS NOT NULL"
25+
)
26+
27+
create index(:users, ["lower(provider_meta ->> 'company') gin_trgm_ops"],
28+
using: :gin,
29+
where: "provider_meta ->> 'company' IS NOT NULL"
30+
)
31+
32+
create index(:users, ["lower(linkedin_meta ->> 'experience') gin_trgm_ops"],
33+
using: :gin,
34+
where: "linkedin_meta ->> 'experience' IS NOT NULL"
35+
)
36+
37+
create index(:repositories, [:user_id, "lower(name)"], where: "name IS NOT NULL")
38+
end
39+
end

0 commit comments

Comments
 (0)