From a6c2ec747ac49e011890eca6ffb80a423406908c Mon Sep 17 00:00:00 2001 From: Teddy Date: Wed, 25 Sep 2024 12:15:26 +0200 Subject: [PATCH] Minor fix psql dq migration failures (#17985) * fix import issue * fix: psql null testCaseResult migration failure --------- Co-authored-by: Chirag Madlani <12962843+chirag-madlani@users.noreply.github.com> --- .../native/1.6.0/mysql/postDataMigrationSQLScript.sql | 5 ++++- .../native/1.6.0/postgres/postDataMigrationSQLScript.sql | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bootstrap/sql/migrations/native/1.6.0/mysql/postDataMigrationSQLScript.sql b/bootstrap/sql/migrations/native/1.6.0/mysql/postDataMigrationSQLScript.sql index ce41487f2a9..85774e35576 100644 --- a/bootstrap/sql/migrations/native/1.6.0/mysql/postDataMigrationSQLScript.sql +++ b/bootstrap/sql/migrations/native/1.6.0/mysql/postDataMigrationSQLScript.sql @@ -24,7 +24,10 @@ CREATE INDEX data_quality_data_time_series_id_index ON data_quality_data_time_se -- Remove VIRTUAL status column from test_case table and remove -- testCaseResult state from testCase; fetch from search repo. ALTER TABLE test_case DROP COLUMN status; -UPDATE test_case SET json = JSON_SET(json, '$.testCaseStatus', JSON_EXTRACT(json, '$.testCaseResult.testCaseStatus')); + +UPDATE test_case SET json = JSON_SET(json, '$.testCaseStatus', JSON_EXTRACT(json, '$.testCaseResult.testCaseStatus')) +WHERE JSON_EXTRACT(json, '$.testCaseResult.testCaseStatus') IS NOT NULL; + ALTER TABLE test_case ADD COLUMN status VARCHAR(56) GENERATED ALWAYS AS (JSON_UNQUOTE(JSON_EXTRACT(json, '$.testCaseStatus'))) STORED; diff --git a/bootstrap/sql/migrations/native/1.6.0/postgres/postDataMigrationSQLScript.sql b/bootstrap/sql/migrations/native/1.6.0/postgres/postDataMigrationSQLScript.sql index 36e4ab6f6d1..206e9c68692 100644 --- a/bootstrap/sql/migrations/native/1.6.0/postgres/postDataMigrationSQLScript.sql +++ b/bootstrap/sql/migrations/native/1.6.0/postgres/postDataMigrationSQLScript.sql @@ -28,7 +28,10 @@ CREATE INDEX IF NOT EXISTS data_quality_data_time_series_id_index ON data_qual -- Remove VIRTUAL status column from test_case table and remove -- testCaseResult state from testCase; fetch from search repo. ALTER TABLE test_case DROP COLUMN status; -UPDATE test_case SET json = jsonb_set(json, '{testCaseStatus}', json->'testCaseResult'->'testCaseStatus'); + +UPDATE test_case SET json = jsonb_set(json, '{testCaseStatus}', json->'testCaseResult'->'testCaseStatus') +WHERE json->'testCaseResult'->'testCaseStatus' IS NOT NULL; + ALTER TABLE test_case ADD COLUMN status VARCHAR(56) GENERATED ALWAYS AS (json ->> 'testCaseStatus') STORED NULL;