mirror of
https://github.com/bitwarden/server.git
synced 2024-12-28 17:57:37 +01:00
7802c2b969
* Do not specify database in migration files * Rename migrations to force them to re-run * Use new migration files * Rename EF migrations
43 lines
1.6 KiB
Plaintext
43 lines
1.6 KiB
Plaintext
CREATE OR REPLACE FUNCTION updatePermissionsJson(permissions jsonb) returns jsonb LANGUAGE plpgsql AS $$
|
|
DECLARE manageAllCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'manageAllCollections'), 'false');
|
|
DECLARE manageAssignedCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'manageAssignedCollections'), 'false');
|
|
|
|
DECLARE createNewCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'createNewCollections'), manageAllCollections);
|
|
DECLARE editAnyCollection jsonb := COALESCE(jsonb_extract_path(permissions, 'editAnyCollection'), manageAllCollections);
|
|
DECLARE deleteAnyCollection jsonb := COALESCE(jsonb_extract_path(permissions, 'deleteAnyCollection'), manageAllCollections);
|
|
|
|
DECLARE editAssignedCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'editAssignedCollections'), manageAssignedCollections);
|
|
DECLARE deleteAssignedCollections jsonb := COALESCE(jsonb_extract_path(permissions, 'deleteAssignedCollections'), manageAssignedCollections);
|
|
|
|
BEGIN
|
|
RETURN
|
|
jsonb_set(
|
|
jsonb_set(
|
|
jsonb_set(
|
|
jsonb_set(
|
|
jsonb_set(
|
|
permissions,
|
|
'{createNewCollections}',
|
|
createNewCollections
|
|
),
|
|
'{editAnyCollection}',
|
|
editAnyCollection
|
|
),
|
|
'{deleteAnyCollection}',
|
|
deleteAnyCollection
|
|
),
|
|
'{editAssignedCollections}',
|
|
editAssignedCollections
|
|
),
|
|
'{deleteAssignedCollections}',
|
|
deleteAssignedCollections
|
|
);
|
|
END
|
|
$$;
|
|
|
|
UPDATE "OrganizationUser"
|
|
SET "Permissions" = updatePermissionsJson("Permissions"::jsonb)::text
|
|
WHERE "Permissions" IS NOT NULL;
|
|
|
|
DROP FUNCTION updatePermissionsJson(jsonb);
|