lemmy/migrations/2022-12-05-110642_registration_mode/down.sql
Nutomic ceff2ec686
Use enum for registration mode setting (#2604)
* Use enum for registration mode setting

* fix tests
2023-01-05 01:42:30 +00:00

31 lines
837 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;