Skip to content

Commit

Permalink
Merge pull request #213 from CirclesUBI/feature/app-450-add-possibili…
Browse files Browse the repository at this point in the history
…ty-for-db-admin-to-disable-an-account-2

adding Session deletion to store procedure
  • Loading branch information
jaensen authored Aug 24, 2023
2 parents e937f55 + fa30e16 commit 9f219ef
Showing 1 changed file with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-- migrate:up
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;
-- Set disabled status
UPDATE
"Profile"
SET
"status" = 'disabled'
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 9f219ef

Please sign in to comment.