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

fixing stored procedure to disable users #219

Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@o-platform/api-server",
"version": "1.0.5",
"version": "1.0.5-1",
"description": "",
"main": "dist/index.js",
"prepublish": "tsc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
-- 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;
-- Copy circlesSafeOwner to disabledCirclesSafeOwner
UPDATE
"Profile"
SET
"disabledCirclesSafeOwner" = "circlesSafeOwner"
WHERE
"circlesAddress" = address;
-- Set disabled status
UPDATE
"Profile"
SET
"status" = 'disabled'
WHERE
"circlesAddress" = address;
-- Disable the Shop for the Person Entry
UPDATE
"Profile"
SET
"shopEnabled" = FALSE
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 for the Orga Entry
UPDATE
"Profile"
SET
"shopEnabled" = FALSE
WHERE
id IN(
SELECT
"createdByProfileId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
-- copy circlesAddress for the Orga Entry
UPDATE
"Profile"
SET
"disabledCirclesAddress" = "circlesAddress"
WHERE
id IN(
SELECT
"memberAtId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
-- Remove circlesAddress for Orga Entry
UPDATE
"Profile"
SET
"circlesAddress" = NULL
WHERE
id IN(
SELECT
"memberAtId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
-- set status for Orga Entry to disabled
UPDATE
"Profile"
SET
"status" = 'disabled'
WHERE
id IN(
SELECT
"memberAtId"
FROM
"Membership"
WHERE
"memberAddress" = address
AND "isAdmin" = TRUE);
END
$$
-- migrate:down
Loading