mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-26 18:00:31 +00:00
29 lines
636 B
SQL
Vendored
29 lines
636 B
SQL
Vendored
-- 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
|
|
delete
|
|
from user_
|
|
where id not in (
|
|
select min(id)
|
|
from user_
|
|
group by lower(name), lower(fedi_name)
|
|
);
|
|
|
|
-- The user index
|
|
create unique index idx_user_name_lower on user_ (lower(name));
|
|
|
|
-- Email lower
|
|
create unique index idx_user_email_lower on user_ (lower(email));
|
|
|
|
-- Set empty emails properly to null
|
|
update user_ set email = null where email = '';
|
|
|