From 21120a0130488d157bb8eedd0d82dd83d60ba2a4 Mon Sep 17 00:00:00 2001 From: Mohit Yadav <105265192+mohityadav766@users.noreply.github.com> Date: Tue, 6 Aug 2024 16:49:23 +0530 Subject: [PATCH] Add Fqn Migration to lowercase (#17311) --- .../mysql/postDataMigrationSQLScript.sql | 21 +++++++++++++++++++ .../native/1.4.7/mysql/schemaChanges.sql | 0 .../postgres/postDataMigrationSQLScript.sql | 21 +++++++++++++++++++ .../native/1.4.7/postgres/schemaChanges.sql | 0 4 files changed, 42 insertions(+) create mode 100644 bootstrap/sql/migrations/native/1.4.7/mysql/postDataMigrationSQLScript.sql create mode 100644 bootstrap/sql/migrations/native/1.4.7/mysql/schemaChanges.sql create mode 100644 bootstrap/sql/migrations/native/1.4.7/postgres/postDataMigrationSQLScript.sql create mode 100644 bootstrap/sql/migrations/native/1.4.7/postgres/schemaChanges.sql diff --git a/bootstrap/sql/migrations/native/1.4.7/mysql/postDataMigrationSQLScript.sql b/bootstrap/sql/migrations/native/1.4.7/mysql/postDataMigrationSQLScript.sql new file mode 100644 index 00000000000..789cbbd4fc9 --- /dev/null +++ b/bootstrap/sql/migrations/native/1.4.7/mysql/postDataMigrationSQLScript.sql @@ -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'))) +); diff --git a/bootstrap/sql/migrations/native/1.4.7/mysql/schemaChanges.sql b/bootstrap/sql/migrations/native/1.4.7/mysql/schemaChanges.sql new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bootstrap/sql/migrations/native/1.4.7/postgres/postDataMigrationSQLScript.sql b/bootstrap/sql/migrations/native/1.4.7/postgres/postDataMigrationSQLScript.sql new file mode 100644 index 00000000000..46b5038286f --- /dev/null +++ b/bootstrap/sql/migrations/native/1.4.7/postgres/postDataMigrationSQLScript.sql @@ -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')) +); \ No newline at end of file diff --git a/bootstrap/sql/migrations/native/1.4.7/postgres/schemaChanges.sql b/bootstrap/sql/migrations/native/1.4.7/postgres/schemaChanges.sql new file mode 100644 index 00000000000..e69de29bb2d