lemmy/migrations/2022-12-05-110642_registration_mode/down.sql
Dessalines be1389420b
Adding SQL format checking via pg_format / pgFormatter (#3740)
* SQL format checking, 1.

* SQL format checking, 2.

* SQL format checking, 3.

* SQL format checking, 4.

* SQL format checking, 5.

* Running pg_format

* Getting rid of comment.

* Upping pg_format version.

* Using git ls-files for sql format check.

* Fixing sql lints.

* Addressing PR comments.
2023-08-02 12:44:51 -04:00

49 lines
928 B
SQL

-- add back old registration columns
ALTER TABLE local_site
ADD COLUMN open_registration boolean NOT NULL DEFAULT TRUE;
ALTER TABLE local_site
ADD COLUMN require_application boolean NOT NULL DEFAULT TRUE;
-- regenerate their values
WITH subquery AS (
SELECT
registration_mode,
CASE WHEN registration_mode = 'closed' THEN
FALSE
ELSE
TRUE
END
FROM
local_site)
UPDATE
local_site
SET
open_registration = subquery.case
FROM
subquery;
WITH subquery AS (
SELECT
registration_mode,
CASE WHEN registration_mode = 'open' THEN
FALSE
ELSE
TRUE
END
FROM
local_site)
UPDATE
local_site
SET
require_application = subquery.case
FROM
subquery;
-- drop new column and type
ALTER TABLE local_site
DROP COLUMN registration_mode;
DROP TYPE registration_mode_enum;