Skip to content

Commit

Permalink
also backing up, and removing circlesSafeOwner
Browse files Browse the repository at this point in the history
  • Loading branch information
codeho committed Aug 24, 2023
1 parent fa30e16 commit 26a1283
Showing 1 changed file with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
-- migrate:up
ALTER TABLE "Profile"
ADD COLUMN "disabledCirclesSafeOwner" TEXT;

CREATE OR REPLACE PROCEDURE sp_DisableProfileAndShop(address varchar(100))
LANGUAGE plpgsql
AS $$
BEGIN
-- Remove Session
DELETE FROM "Session"
WHERE "Session"."profileId" IN(
SELECT
"id"
FROM
"Profile"
WHERE
"circlesAddress" = address);
-- Copy circlesAddress to disabledCirclesAddress
UPDATE
"Profile"
SET
"disabledCirclesAddress" = "circlesAddress"
WHERE
"circlesAddress" = address;
-- Copy circlesSafeOwner to disabledCirclesSafeOwner
UPDATE
"Profile"
SET
"disabledCirclesSafeOwner" = "circlesSafeOwner"
WHERE
"circlesAddress" = address;
-- Set disabled status
UPDATE
"Profile"
SET
"status" = 'disabled'
WHERE
"circlesAddress" = address;
-- Remove circlesSafeOwner
UPDATE
"Profile"
SET
"circlesSafeOwner" = NULL
WHERE
"circlesAddress" = address;
-- Remove CirclesAddress
UPDATE
"Profile"
SET
"circlesAddress" = NULL
WHERE
"circlesAddress" = address;
-- Disable the Shop
UPDATE
"Profile"
SET
"shopEnabled" = FALSE
WHERE
id IN(
SELECT
"memberAtId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
END
$$
-- migrate:down

0 comments on commit 26a1283

Please sign in to comment.