2022-01-26 17:57:16 +00:00
|
|
|
-- Add the column back
|
2023-08-02 16:44:51 +00:00
|
|
|
ALTER TABLE site
|
|
|
|
ADD COLUMN creator_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE;
|
2022-01-26 17:57:16 +00:00
|
|
|
|
|
|
|
-- Add the data, selecting the highest admin
|
2023-08-02 16:44:51 +00:00
|
|
|
UPDATE
|
|
|
|
site
|
|
|
|
SET
|
|
|
|
creator_id = sub.id
|
|
|
|
FROM (
|
|
|
|
SELECT
|
|
|
|
id
|
|
|
|
FROM
|
|
|
|
person
|
|
|
|
WHERE
|
|
|
|
admin = TRUE
|
|
|
|
LIMIT 1) AS sub;
|
2022-01-26 17:57:16 +00:00
|
|
|
|
|
|
|
-- Set to not null
|
2023-08-02 16:44:51 +00:00
|
|
|
ALTER TABLE site
|
|
|
|
ALTER COLUMN creator_id SET NOT NULL;
|
|
|
|
|