Skip to content

Commit

Permalink
fix(appeal): fix 'permissions' column addition migration script (#273) (
Browse files Browse the repository at this point in the history
#274)

* fix(appeal): fix 'permissions' column addition migration script

* fix: add resource type filter
  • Loading branch information
rahmatrhd authored Sep 6, 2022
1 parent dd5c4e1 commit 7f4eabe
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ WITH "provider_resources" AS (
jsonb_array_elements("config" -> 'resources') AS "resource"
FROM
"providers"
WHERE
"type" NOT IN ('gcloud_iam', 'noop')
),
"provider_role_configs" AS (
SELECT
Expand Down Expand Up @@ -48,6 +50,7 @@ SET
"permissions" = (
CASE
WHEN "resources"."provider_type" = 'gcloud_iam' THEN string_to_array(a."role", ',')
WHEN "resources"."provider_type" = 'noop' THEN '{}'
ELSE "provider_roles"."permissions"
END
)
Expand All @@ -56,6 +59,8 @@ FROM
LEFT JOIN "resources" ON a."resource_id" = "resources"."id"
LEFT JOIN "provider_roles" ON "resources"."provider_type" = "provider_roles"."type"
AND "resources"."provider_urn" = "provider_roles"."urn"
AND "resources"."type" = "provider_roles"."resource_type"
AND a."role" = "provider_roles"."role"
WHERE
"appeals"."id" = a."id";

Expand Down

0 comments on commit 7f4eabe

Please sign in to comment.