Skip to content

Commit 9fe5b1e

Browse files
authored
fix: Revert "fix: revert fallback on btree indexes when hash is unavailable" (#1859)
Reverts #1858 Reverse reverse, cha cha real smooth now
1 parent a19d62d commit 9fe5b1e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

migrations/20240427152123_add_one_time_tokens_table.up.sql

+9-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@ do $$ begin
2424
check (char_length(token_hash) > 0)
2525
);
2626

27-
create index if not exists one_time_tokens_token_hash_hash_idx on {{ index .Options "Namespace" }}.one_time_tokens using hash (token_hash);
28-
create index if not exists one_time_tokens_relates_to_hash_idx on {{ index .Options "Namespace" }}.one_time_tokens using hash (relates_to);
27+
begin
28+
create index if not exists one_time_tokens_token_hash_hash_idx on {{ index .Options "Namespace" }}.one_time_tokens using hash (token_hash);
29+
create index if not exists one_time_tokens_relates_to_hash_idx on {{ index .Options "Namespace" }}.one_time_tokens using hash (relates_to);
30+
exception when others then
31+
-- Fallback to btree indexes if hash creation fails
32+
create index if not exists one_time_tokens_token_hash_hash_idx on {{ index .Options "Namespace" }}.one_time_tokens using btree (token_hash);
33+
create index if not exists one_time_tokens_relates_to_hash_idx on {{ index .Options "Namespace" }}.one_time_tokens using btree (relates_to);
34+
end;
35+
2936
create unique index if not exists one_time_tokens_user_id_token_type_key on {{ index .Options "Namespace" }}.one_time_tokens (user_id, token_type);
3037
end $$;

0 commit comments

Comments
 (0)