mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-02 11:13:51 +00:00
* [0.19] Fixing active counts slow queries. (#5907) * Fixing active counts slow queries. * Simplify back to str tuple * Batch site and community updates * Using update from temp table * Making aggs temp table use interval name. * Make dev setup use optimized postgres. * Addressing PR comments. * Use ref * Removing system custom info from customPostgresql.conf * Forgot to remove old scheduled tasks. * Making sure migrations aren't missing anything from release/v0.19 Checked using git diff --diff-filter D --stat release/v0.19 migrations * Rename all migrations to come after release/v0.19 migrations * Add liked_at is not null check.
22 lines
483 B
SQL
22 lines
483 B
SQL
-- lemmy requires (username + instance_id) to be unique
|
|
-- delete any existing duplicates
|
|
DELETE FROM person p1 USING (
|
|
SELECT
|
|
min(id) AS id,
|
|
name,
|
|
instance_id
|
|
FROM
|
|
person
|
|
GROUP BY
|
|
name,
|
|
instance_id
|
|
HAVING
|
|
count(*) > 1) p2
|
|
WHERE
|
|
p1.name = p2.name
|
|
AND p1.instance_id = p2.instance_id
|
|
AND p1.id <> p2.id;
|
|
|
|
ALTER TABLE person
|
|
ADD CONSTRAINT person_name_instance_unique UNIQUE (name, instance_id);
|
|
|