-
Notifications
You must be signed in to change notification settings - Fork 419
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: update migration for creating partial indices (#463)
- Loading branch information
1 parent
b02f838
commit 48d6554
Showing
1 changed file
with
7 additions
and
5 deletions.
There are no files selected for viewing
12 changes: 7 additions & 5 deletions
12
...ions/20220429010200_add_unique_idx.up.sql → ...ions/20220429102000_add_unique_idx.up.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
-- add partial unique indices to confirmation_token, recovery_token, email_change_token_current, email_change_token_new, phone_change_token, reauthentication_token | ||
-- ignores partial unique index creation on fields which contain empty strings, whitespaces or purely numeric otps | ||
|
||
DROP INDEX IF EXISTS confirmation_token_idx; | ||
DROP INDEX IF EXISTS recovery_token_idx; | ||
DROP INDEX IF EXISTS email_change_token_current_idx; | ||
DROP INDEX IF EXISTS email_change_token_new_idx; | ||
DROP INDEX IF EXISTS reauthentication_token_idx; | ||
|
||
CREATE UNIQUE INDEX IF NOT EXISTS confirmation_token_idx ON auth.users USING btree (confirmation_token) WHERE confirmation_token != '' AND confirmation_token !~ '^[0-9 ]*$'; | ||
CREATE UNIQUE INDEX IF NOT EXISTS recovery_token_idx ON auth.users USING btree (recovery_token) WHERE recovery_token != '' AND confirmation_token !~ '^[0-9 ]*$'; | ||
CREATE UNIQUE INDEX IF NOT EXISTS email_change_token_current_idx ON auth.users USING btree (email_change_token_current) WHERE email_change_token_current != ''; | ||
CREATE UNIQUE INDEX IF NOT EXISTS email_change_token_new_idx ON auth.users USING btree (email_change_token_new) WHERE email_change_token_new != ''; | ||
CREATE UNIQUE INDEX IF NOT EXISTS reauthentication_token_idx ON auth.users USING btree (reauthentication_token) WHERE reauthentication_token != '' AND confirmation_token !~ '^[0-9 ]*$'; | ||
CREATE UNIQUE INDEX IF NOT EXISTS confirmation_token_idx ON auth.users USING btree (confirmation_token) WHERE confirmation_token !~ '^[0-9 ]*$'; | ||
CREATE UNIQUE INDEX IF NOT EXISTS recovery_token_idx ON auth.users USING btree (recovery_token) WHERE recovery_token !~ '^[0-9 ]*$'; | ||
CREATE UNIQUE INDEX IF NOT EXISTS email_change_token_current_idx ON auth.users USING btree (email_change_token_current) WHERE email_change_token_current !~ '^[0-9 ]*$'; | ||
CREATE UNIQUE INDEX IF NOT EXISTS email_change_token_new_idx ON auth.users USING btree (email_change_token_new) WHERE email_change_token_new !~ '^[0-9 ]*$'; | ||
CREATE UNIQUE INDEX IF NOT EXISTS reauthentication_token_idx ON auth.users USING btree (reauthentication_token) WHERE reauthentication_token !~ '^[0-9 ]*$'; |