Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding Session deletion to store procedure #213

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading