2023-01-05 01:42:30 +00:00
|
|
|
-- create enum for registration modes
|
2023-08-02 16:44:51 +00:00
|
|
|
CREATE TYPE registration_mode_enum AS enum (
|
|
|
|
'closed',
|
|
|
|
'require_application',
|
|
|
|
'open'
|
|
|
|
);
|
2023-01-05 01:42:30 +00:00
|
|
|
|
|
|
|
-- use this enum for registration mode setting
|
2023-08-02 16:44:51 +00:00
|
|
|
ALTER TABLE local_site
|
|
|
|
ADD COLUMN registration_mode registration_mode_enum NOT NULL DEFAULT 'require_application';
|
2023-01-05 01:42:30 +00:00
|
|
|
|
|
|
|
-- generate registration mode value from previous settings
|
2023-08-02 16:44:51 +00:00
|
|
|
WITH subquery AS (
|
|
|
|
SELECT
|
|
|
|
open_registration,
|
|
|
|
require_application,
|
|
|
|
CASE WHEN open_registration = FALSE THEN
|
|
|
|
'closed'::registration_mode_enum
|
|
|
|
WHEN open_registration = TRUE
|
|
|
|
AND require_application = TRUE THEN
|
|
|
|
'require_application'
|
|
|
|
ELSE
|
|
|
|
'open'
|
|
|
|
END
|
|
|
|
FROM
|
|
|
|
local_site)
|
|
|
|
UPDATE
|
|
|
|
local_site
|
|
|
|
SET
|
|
|
|
registration_mode = subquery.case
|
|
|
|
FROM
|
|
|
|
subquery;
|
2023-01-05 01:42:30 +00:00
|
|
|
|
|
|
|
-- drop old registration settings
|
2023-08-02 16:44:51 +00:00
|
|
|
ALTER TABLE local_site
|
|
|
|
DROP COLUMN open_registration;
|
|
|
|
|
|
|
|
ALTER TABLE local_site
|
|
|
|
DROP COLUMN require_application;
|
|
|
|
|