Add Fqn Migration to lowercase (#17311)

This commit is contained in:
Mohit Yadav 2024-08-06 16:49:23 +05:30 committed by GitHub
parent 92b2c6c353
commit 21120a0130
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,21 @@
-- Remove Duplicate FullyQualifiedName and lowercase
WITH cte AS (
SELECT
id,
ROW_NUMBER() OVER (PARTITION BY LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.fullyQualifiedName'))) ORDER BY id) as rn
FROM
user_entity
)
DELETE FROM user_entity
WHERE id IN (
SELECT id
FROM cte
WHERE rn > 1
);
UPDATE user_entity
SET json = JSON_SET(
json,
'$.fullyQualifiedName',
LOWER(JSON_UNQUOTE(JSON_EXTRACT(json, '$.fullyQualifiedName')))
);

View File

@ -0,0 +1,21 @@
-- Remove Duplicate FullyQualifiedName and lowercase
WITH cte AS (
SELECT
id,
ROW_NUMBER() OVER (PARTITION BY to_jsonb(LOWER(json->>'fullyQualifiedName')) ORDER BY id) as rn
FROM
user_entity
)
DELETE from user_entity
WHERE id IN (
SELECT id
FROM cte
WHERE rn > 1
);
UPDATE user_entity
SET json = jsonb_set(
json,
'{fullyQualifiedName}',
to_jsonb(LOWER(json->>'fullyQualifiedName'))
);