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.
39 lines
1.2 KiB
SQL
39 lines
1.2 KiB
SQL
-- This removes the simple enable_downvotes setting, in favor of an
|
|
-- expanded federation mode type for post/comment up/downvotes.
|
|
-- Create the federation mode enum
|
|
CREATE TYPE federation_mode_enum AS ENUM (
|
|
'All',
|
|
'Local',
|
|
'Disable'
|
|
);
|
|
|
|
-- Add the new columns
|
|
ALTER TABLE local_site
|
|
ADD COLUMN post_upvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL,
|
|
ADD COLUMN post_downvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL,
|
|
ADD COLUMN comment_upvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL,
|
|
ADD COLUMN comment_downvotes federation_mode_enum DEFAULT 'All'::federation_mode_enum NOT NULL;
|
|
|
|
-- Copy over the enable_downvotes into the post and comment downvote settings
|
|
WITH subquery AS (
|
|
SELECT
|
|
enable_downvotes,
|
|
CASE WHEN enable_downvotes = TRUE THEN
|
|
'All'::federation_mode_enum
|
|
ELSE
|
|
'Disable'::federation_mode_enum
|
|
END
|
|
FROM
|
|
local_site)
|
|
UPDATE
|
|
local_site
|
|
SET
|
|
post_downvotes = subquery.case,
|
|
comment_downvotes = subquery.case
|
|
FROM
|
|
subquery;
|
|
|
|
-- Drop the enable_downvotes column
|
|
ALTER TABLE local_site
|
|
DROP COLUMN enable_downvotes;
|
|
|