Merge pull request #1951 from LemmyNet/fix_ap_id_dupes_query

Fix API dupes query. #1878
email-verification
Dessalines 2021-11-23 14:37:58 -05:00 committed by GitHub
commit 7363b19f01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -6,13 +6,13 @@ delete from activity where ap_id is null;
alter table activity alter column ap_id set not null; alter table activity alter column ap_id set not null;
-- Delete dupes, keeping the first one -- Delete dupes, keeping the first one
delete delete from activity a using (
select min(id) as id, ap_id
from activity from activity
where id not in ( group by ap_id having count(*) > 1
select min(id) ) b
from activity where a.ap_id = b.ap_id
group by ap_id and a.id <> b.id;
);
-- The index -- The index
create unique index idx_activity_ap_id on activity(ap_id); create unique index idx_activity_ap_id on activity(ap_id);