mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-09-03 03:33:50 +00:00
Update mod_ban.instance_id for existing entries (#5627)
* Update mod_ban.instance_id for existing entries * Update mod_ban.instance_id in site_person_ban migration
This commit is contained in:
parent
215dfa33df
commit
4b877c5119
1 changed files with 14 additions and 1 deletions
|
@ -5,7 +5,20 @@ ALTER TABLE instance_actions
|
||||||
ADD COLUMN ban_expires timestamptz;
|
ADD COLUMN ban_expires timestamptz;
|
||||||
|
|
||||||
ALTER TABLE mod_ban
|
ALTER TABLE mod_ban
|
||||||
ADD COLUMN instance_id int NOT NULL REFERENCES instance ON UPDATE CASCADE ON DELETE CASCADE;
|
ADD COLUMN instance_id int REFERENCES instance ON UPDATE CASCADE ON DELETE CASCADE;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
mod_ban
|
||||||
|
SET
|
||||||
|
instance_id = person.instance_id
|
||||||
|
FROM
|
||||||
|
person
|
||||||
|
WHERE
|
||||||
|
mod_ban.instance_id IS NULL
|
||||||
|
AND mod_ban.mod_person_id = person.id;
|
||||||
|
|
||||||
|
ALTER TABLE mod_ban
|
||||||
|
ALTER COLUMN instance_id SET NOT NULL;
|
||||||
|
|
||||||
-- insert existing bans into instance_actions table, assuming they were all banned from home instance
|
-- insert existing bans into instance_actions table, assuming they were all banned from home instance
|
||||||
INSERT INTO instance_actions (person_id, instance_id, received_ban, ban_expires)
|
INSERT INTO instance_actions (person_id, instance_id, received_ban, ban_expires)
|
||||||
|
|
Loading…
Reference in a new issue