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

This commit is contained in:
Omar López authored and GitHub committed 2024-03-28 11:36:27 -07:00
1 parent 622160ea17
commit 159bbb53b6
4 files changed
+89

No files matched your search

@@ -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:]]';