Skip to content

Commit 158e473

Browse files
authored
fix: make drop_uniqueness_constraint_on_phone idempotent (#1817)
1 parent 26d2e36 commit 158e473

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

migrations/20240806073726_drop_uniqueness_constraint_on_phone.up.sql

+10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
alter table {{ index .Options "Namespace" }}.mfa_factors drop constraint if exists mfa_factors_phone_key;
22
do $$
33
begin
4+
-- if both indexes exist, it means that the schema_migrations table was truncated and the migrations had to be rerun
5+
if (
6+
select count(*) = 2
7+
from pg_indexes
8+
where indexname in ('unique_verified_phone_factor', 'unique_phone_factor_per_user')
9+
and schemaname = '{{ index .Options "Namespace" }}'
10+
) then
11+
execute 'drop index {{ index .Options "Namespace" }}.unique_verified_phone_factor';
12+
end if;
13+
414
if exists (
515
select 1
616
from pg_indexes

0 commit comments

Comments
 (0)