Skip to content

Commit

Permalink
adding Session deletion to store procedure
Browse files Browse the repository at this point in the history
  • Loading branch information
codeho committed Aug 24, 2023
1 parent e937f55 commit fa30e16
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 fa30e16

Please sign in to comment.