From 1efd25a0e5b92688cc53cb22b1a9f5e8666eb7e7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Sun, 22 Jan 2017 17:00:56 +0100 Subject: [PATCH] Exclude from unique index users marked for delete. --- backend/resources/migrations/0002.auth.up.sql | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/resources/migrations/0002.auth.up.sql b/backend/resources/migrations/0002.auth.up.sql index eb722f845..320e2e3d2 100644 --- a/backend/resources/migrations/0002.auth.up.sql +++ b/backend/resources/migrations/0002.auth.up.sql @@ -24,10 +24,12 @@ VALUES ('00000000-0000-0000-0000-000000000000'::uuid, ''::bytea); CREATE UNIQUE INDEX users_username_idx - ON users USING btree (username); + ON users WHERE deleted_at is null + USING btree (username) ; CREATE UNIQUE INDEX users_email_idx - ON users USING btree (email); + ON users WHERE deleted_at is null + USING btree (email); CREATE TRIGGER users_modified_at_tgr BEFORE UPDATE ON users FOR EACH ROW EXECUTE PROCEDURE update_modified_at();