2020-02-02 01:11:12 +00:00
|
|
|
-- Add case insensitive username and email uniqueness
|
|
|
|
-- An example of showing the dupes:
|
|
|
|
-- select
|
|
|
|
-- max(id) as id,
|
|
|
|
-- lower(name) as lname,
|
|
|
|
-- count(*)
|
|
|
|
-- from user_
|
|
|
|
-- group by lower(name)
|
|
|
|
-- having count(*) > 1;
|
|
|
|
-- Delete username dupes, keeping the first one
|
2023-08-02 16:44:51 +00:00
|
|
|
DELETE FROM user_
|
|
|
|
WHERE id NOT IN (
|
|
|
|
SELECT
|
|
|
|
min(id)
|
|
|
|
FROM
|
|
|
|
user_
|
|
|
|
GROUP BY
|
|
|
|
lower(name),
|
|
|
|
lower(fedi_name));
|
2020-02-02 01:11:12 +00:00
|
|
|
|
2023-08-02 16:44:51 +00:00
|
|
|
-- The user index
|
|
|
|
CREATE UNIQUE INDEX idx_user_name_lower ON user_ (lower(name));
|
2020-02-02 01:11:12 +00:00
|
|
|
|
|
|
|
-- Email lower
|
2023-08-02 16:44:51 +00:00
|
|
|
CREATE UNIQUE INDEX idx_user_email_lower ON user_ (lower(email));
|
2020-02-02 01:11:12 +00:00
|
|
|
|
|
|
|
-- Set empty emails properly to null
|
2023-08-02 16:44:51 +00:00
|
|
|
UPDATE
|
|
|
|
user_
|
|
|
|
SET
|
|
|
|
email = NULL
|
|
|
|
WHERE
|
|
|
|
email = '';
|
2020-02-02 01:11:12 +00:00
|
|
|
|