chore: fix down migration 196 (#13006)

It didn't account for null values.
This commit is contained in:
Colin Adler 2024-04-18 18:47:02 -05:00 committed by GitHub
parent 319fd5bf1d
commit 3aa0d73811
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 5 deletions

View File

@ -11,11 +11,15 @@ CREATE OR REPLACE FUNCTION revert_migrate_external_auth_providers_to_jsonb(jsonb
DECLARE
result text[];
BEGIN
SELECT
array_agg(id::text) INTO result
FROM (
SELECT
jsonb_array_elements($1) ->> 'id' AS id) AS external_auth_provider_ids;
IF jsonb_typeof($1) = 'null' THEN
result := '{}';
ELSE
SELECT
array_agg(id::text) INTO result
FROM (
SELECT
jsonb_array_elements($1) ->> 'id' AS id) AS external_auth_provider_ids;
END IF;
RETURN result;
END;
$$;