]> Untitled Git - lemmy.git/blob - migrations/2022-01-20-160328_remove_site_creator/down.sql
Speedup CI (#3852)
[lemmy.git] / migrations / 2022-01-20-160328_remove_site_creator / down.sql
1 --  Add the column back
2 ALTER TABLE site
3     ADD COLUMN creator_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE;
4
5 -- Add the data, selecting the highest admin
6 UPDATE
7     site
8 SET
9     creator_id = sub.id
10 FROM (
11     SELECT
12         id
13     FROM
14         person
15     WHERE
16         admin = TRUE
17     LIMIT 1) AS sub;
18
19 -- Set to not null
20 ALTER TABLE site
21     ALTER COLUMN creator_id SET NOT NULL;
22