mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-24 20:01:34 +00:00
be1389420b
* SQL format checking, 1. * SQL format checking, 2. * SQL format checking, 3. * SQL format checking, 4. * SQL format checking, 5. * Running pg_format * Getting rid of comment. * Upping pg_format version. * Using git ls-files for sql format check. * Fixing sql lints. * Addressing PR comments.
26 lines
558 B
SQL
26 lines
558 B
SQL
-- Add the column back
|
|
ALTER TABLE community
|
|
ADD COLUMN creator_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE;
|
|
|
|
-- Recreate the index
|
|
CREATE INDEX idx_community_creator ON community (creator_id);
|
|
|
|
-- Add the data, selecting the highest mod
|
|
UPDATE
|
|
community
|
|
SET
|
|
creator_id = sub.person_id
|
|
FROM (
|
|
SELECT
|
|
cm.community_id,
|
|
cm.person_id
|
|
FROM
|
|
community_moderator cm
|
|
LIMIT 1) AS sub
|
|
WHERE
|
|
id = sub.community_id;
|
|
|
|
-- Set to not null
|
|
ALTER TABLE community
|
|
ALTER COLUMN creator_id SET NOT NULL;
|
|
|