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;