You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lemmy/migrations/2024-09-20-134838_add_feder.../down.sql

32 lines
691 B
SQL

-- Add back the enable_downvotes column
ALTER TABLE local_site
ADD COLUMN enable_downvotes boolean DEFAULT TRUE NOT NULL;
-- regenerate their values (from post_downvotes alone)
WITH subquery AS (
SELECT
post_downvotes,
CASE WHEN post_downvotes = 'Disable'::federation_mode_enum THEN
FALSE
ELSE
TRUE
END
FROM
local_site)
UPDATE
local_site
SET
enable_downvotes = subquery.case
FROM
subquery;
-- Drop the new columns
ALTER TABLE local_site
DROP COLUMN post_upvotes,
DROP COLUMN post_downvotes,
DROP COLUMN comment_upvotes,
DROP COLUMN comment_downvotes;
DROP TYPE federation_mode_enum;