lemmy/migrations/2025-08-01-000014_private-community/down.sql
Dessalines 644a448aa9
[main] Fixing active counts slow queries. (#5907) (#5917)
* [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.
2025-08-09 21:57:38 +02:00

52 lines
1.2 KiB
PL/PgSQL

-- Remove private visibility
ALTER TYPE community_visibility RENAME TO community_visibility__;
CREATE TYPE community_visibility AS enum (
'Public',
'LocalOnly'
);
ALTER TABLE community
ALTER COLUMN visibility DROP DEFAULT;
ALTER TABLE community
ALTER COLUMN visibility TYPE community_visibility
USING visibility::text::community_visibility;
ALTER TABLE community
ALTER COLUMN visibility SET DEFAULT 'Public';
DROP TYPE community_visibility__;
-- Revert community follower changes
CREATE OR REPLACE FUNCTION convert_follower_state (s community_follower_state)
RETURNS bool
LANGUAGE sql
AS $$
SELECT
CASE WHEN s = 'Pending' THEN
TRUE
ELSE
FALSE
END
$$;
ALTER TABLE community_follower
ALTER COLUMN state TYPE bool
USING convert_follower_state (state);
DROP FUNCTION convert_follower_state;
ALTER TABLE community_follower
ALTER COLUMN state SET DEFAULT FALSE;
ALTER TABLE community_follower RENAME COLUMN state TO pending;
DROP TYPE community_follower_state;
ALTER TABLE community_follower
DROP COLUMN approver_id;
ALTER TABLE ONLY local_site
ALTER COLUMN federation_signed_fetch SET DEFAULT FALSE;