mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-16 09:24:00 +00:00
Fix API dupes query. #1878
This commit is contained in:
parent
7f01d8cde6
commit
f6b96370b8
1 changed files with 6 additions and 6 deletions
|
@ -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 (
|
||||||
from activity
|
select min(id) as id, ap_id
|
||||||
where id not in (
|
|
||||||
select min(id)
|
|
||||||
from activity
|
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
|
-- The index
|
||||||
create unique index idx_activity_ap_id on activity(ap_id);
|
create unique index idx_activity_ap_id on activity(ap_id);
|
||||||
|
|
Loading…
Reference in a new issue