chore: adds useful SQL scripts for devops (#14068)

This commit is contained in:
Omar López
2024-03-28 11:36:27 -07:00
committed by GitHub
parent 622160ea17
commit 159bbb53b6
4 changed files with 89 additions and 0 deletions
@@ -0,0 +1,13 @@
-- Find users with uppercase characters in email
SELECT * FROM users u WHERE u.email ~ '[[:upper:]]';
-- Find emails with case insensitive duplicates
SELECT lower(email) FROM users GROUP BY lower(email) HAVING count(*) > 1;
-- List emails with their case insensitive duplicates
SELECT * FROM users u WHERE LOWER(u.email) IN (
SELECT lower(email) FROM users GROUP BY lower(email) HAVING count(*) > 1
);
-- Lowercase all user emails (This will fail if there are case insensitive duplicates)
UPDATE users SET email = lower(email) WHERE email ~ '[[:upper:]]';