mirror of https://github.com/LemmyNet/lemmy.git
Fix API dupes query. #1878
parent
8f019fde9b
commit
5b220acbac
|
@ -6,13 +6,13 @@ delete from activity where ap_id is null;
|
|||
alter table activity alter column ap_id set not null;
|
||||
|
||||
-- Delete dupes, keeping the first one
|
||||
delete
|
||||
from activity
|
||||
where id not in (
|
||||
select min(id)
|
||||
delete from activity a using (
|
||||
select min(id) as id, ap_id
|
||||
from activity
|
||||
group by ap_id
|
||||
);
|
||||
group by ap_id having count(*) > 1
|
||||
) b
|
||||
where a.ap_id = b.ap_id
|
||||
and a.id <> b.id;
|
||||
|
||||
-- The index
|
||||
create unique index idx_activity_ap_id on activity(ap_id);
|
||||
|
|
Loading…
Reference in New Issue