diff --git a/bootstrap/sql/migrations/native/1.5.0/mysql/schemaChanges.sql b/bootstrap/sql/migrations/native/1.5.0/mysql/schemaChanges.sql index 0217748f88b..c3bf466dd41 100644 --- a/bootstrap/sql/migrations/native/1.5.0/mysql/schemaChanges.sql +++ b/bootstrap/sql/migrations/native/1.5.0/mysql/schemaChanges.sql @@ -209,16 +209,13 @@ WHERE JSON_CONTAINS_PATH(json, 'one', '$.feedInfo.entitySpecificInfo.updatedOwne AND JSON_TYPE(JSON_EXTRACT(json, '$.feedInfo.entitySpecificInfo.updatedOwner')) <> 'ARRAY'; -- Update entity_extension to move owner to array -UPDATE entity_extension -SET json = JSON_SET( - json, - '$.owner', +update entity_extension set json = JSON_SET( + JSON_REMOVE(json, '$.owner'), + '$.owners', JSON_ARRAY( JSON_EXTRACT(json, '$.owner') ) -) -WHERE JSON_CONTAINS_PATH(json, 'one', '$.owner') -AND JSON_TYPE(JSON_EXTRACT(json, '$.owner')) <> 'ARRAY'; +) where json -> '$.owner' is not null; ALTER TABLE test_case MODIFY COLUMN `name` VARCHAR(512) GENERATED ALWAYS AS (json ->> '$.name') NOT NULL; diff --git a/bootstrap/sql/migrations/native/1.5.0/postgres/schemaChanges.sql b/bootstrap/sql/migrations/native/1.5.0/postgres/schemaChanges.sql index aa41e891629..fbae1bca5e9 100644 --- a/bootstrap/sql/migrations/native/1.5.0/postgres/schemaChanges.sql +++ b/bootstrap/sql/migrations/native/1.5.0/postgres/schemaChanges.sql @@ -191,15 +191,8 @@ WHERE jsonb_path_exists(json, '$.feedInfo.entitySpecificInfo.updatedOwner') AND jsonb_typeof(json->'feedInfo'->'entitySpecificInfo'->'updatedOwner') <> 'array'; -- Update entity_extension to move owner to array -UPDATE entity_extension -SET json = jsonb_set( - json, - '{owner}', - to_jsonb(ARRAY[jsonb_path_query_first(json, '$.owner')]) -) -WHERE jsonb_path_exists(json, '$.owner') - AND jsonb_path_query_first(json, '$.owner ? (@ != null)') IS NOT null - AND jsonb_typeof(json->'owner') <> 'array'; +update entity_extension set json = jsonb_set(json#-'{owner}', '{owners}', +jsonb_build_array(json#>'{owner}')) where json #>> '{owner}' is not null; ALTER TABLE test_case ALTER COLUMN name TYPE VARCHAR(512);