lemmy/migrations/2022-01-20-160328_remove_site_creator/down.sql
Dessalines e36ad9d984
Removing the site creator, adding leave_admin. Fixes #1808 (#2052)
* Removing the site creator, adding leave_admin. Fixes #1808

* Making sure there's at least one admin. Fixing unit tests
2022-01-26 17:57:16 +00:00

14 lines
351 B
SQL

-- Add the column back
alter table site add column creator_id int references person on update cascade on delete cascade;
-- Add the data, selecting the highest admin
update site
set creator_id = sub.id
from (
select id from person
where admin = true
limit 1
) as sub;
-- Set to not null
alter table site alter column creator_id set not null;