diff --git a/bootstrap/sql/migrations/native/1.2.3/mysql/schemaChanges.sql b/bootstrap/sql/migrations/native/1.2.3/mysql/schemaChanges.sql index b22ea61a8b3..e69de29bb2d 100644 --- a/bootstrap/sql/migrations/native/1.2.3/mysql/schemaChanges.sql +++ b/bootstrap/sql/migrations/native/1.2.3/mysql/schemaChanges.sql @@ -1,85 +0,0 @@ --- update service type to UnityCatalog - update database entity -UPDATE database_entity de -SET de.json = JSON_INSERT( - JSON_REMOVE(de.json, '$.serviceType'), - '$.serviceType', - 'UnityCatalog' - ) -where id in ( -select toId from entity_relationship er -where - fromEntity = 'databaseService' - and toEntity = 'database' - and fromId in ( - select id from dbservice_entity dbe - where - serviceType = 'Databricks' - and JSON_EXTRACT( - dbe.json, '$.connection.config.useUnityCatalog' - ) = true - )); - - --- update service type to UnityCatalog - update database schema entity -UPDATE database_schema_entity dse -SET dse.json = JSON_INSERT( - JSON_REMOVE(dse.json, '$.serviceType'), - '$.serviceType', - 'UnityCatalog' - ) -where JSON_EXTRACT(dse.json, '$.database.id') in ( -select toId from entity_relationship er -where - fromEntity = 'databaseService' - and toEntity = 'database' - and fromId in ( - select id from dbservice_entity dbe - where - serviceType = 'Databricks' - and JSON_EXTRACT( - dbe.json, '$.connection.config.useUnityCatalog' - ) = true - )); - - --- update service type to UnityCatalog - update table entity -UPDATE table_entity te -SET te.json = JSON_INSERT( - JSON_REMOVE(te.json, '$.serviceType'), - '$.serviceType', - 'UnityCatalog' - ) -where JSON_EXTRACT(te.json, '$.database.id') in ( -select toId from entity_relationship er -where - fromEntity = 'databaseService' - and toEntity = 'database' - and fromId in ( - select id from dbservice_entity dbe - where - serviceType = 'Databricks' - and JSON_EXTRACT( - dbe.json, '$.connection.config.useUnityCatalog' - ) = true - )); - - --- update service type to UnityCatalog - update db service entity -UPDATE dbservice_entity de -SET de.json = JSON_INSERT( - JSON_REMOVE(de.json, '$.connection.config.type'), - '$.connection.config.type', - 'UnityCatalog' - ),de.json = JSON_INSERT( - JSON_REMOVE(de.json, '$.serviceType'), - '$.serviceType', - 'UnityCatalog' - ) -WHERE de.serviceType = 'Databricks' - AND JSON_EXTRACT(de.json, '$.connection.config.useUnityCatalog') = True -; - --- remove `useUnityCatalog` flag from service connection details of databricks -UPDATE dbservice_entity de -SET de.json = JSON_REMOVE(de.json, '$.connection.config.useUnityCatalog') -WHERE de.serviceType IN ('Databricks','UnityCatalog'); diff --git a/bootstrap/sql/migrations/native/1.2.3/postgres/schemaChanges.sql b/bootstrap/sql/migrations/native/1.2.3/postgres/schemaChanges.sql index c6b4433025c..e77b9233afd 100644 --- a/bootstrap/sql/migrations/native/1.2.3/postgres/schemaChanges.sql +++ b/bootstrap/sql/migrations/native/1.2.3/postgres/schemaChanges.sql @@ -11,86 +11,3 @@ WHERE json #>> '{pipelineType}' = 'metadata' AND json #>> '{sourceConfig,config,type}' = 'DatabaseMetadata' AND json #>> '{sourceConfig,config,viewParsingTimeoutLimit}' is not null; - - --- update service type to UnityCatalog - update database entity -UPDATE database_entity de -SET json = jsonb_set( - json #- '{serviceType}', - '{serviceType}', - '"UnityCatalog"', - true - ) -where id in ( -select toId from entity_relationship er -where - fromEntity = 'databaseService' - and toEntity = 'database' - and fromId in ( - select id from dbservice_entity dbe - where - serviceType = 'Databricks' - and (dbe.json #>> '{connection,config,useUnityCatalog}')::bool = true - )); - - --- update service type to UnityCatalog - update database schema entity -UPDATE database_schema_entity dse -SET json = jsonb_set( - json #- '{serviceType}', - '{serviceType}', - '"UnityCatalog"', - true - ) -where json #>> '{database,id}' in ( -select toId from entity_relationship er -where - fromEntity = 'databaseService' - and toEntity = 'database' - and fromId in ( - select id from dbservice_entity dbe - where - serviceType = 'Databricks' - and (dbe.json #>> '{connection,config,useUnityCatalog}')::bool = true - )); - --- update service type to UnityCatalog - update table entity -UPDATE table_entity te -SET json = jsonb_set( - json #- '{serviceType}', - '{serviceType}', - '"UnityCatalog"', - true - ) -where json #>> '{database,id}' in ( -select toId from entity_relationship er -where - fromEntity = 'databaseService' - and toEntity = 'database' - and fromId in ( - select id from dbservice_entity dbe - where - serviceType = 'Databricks' - and (dbe.json #>> '{connection,config,useUnityCatalog}')::bool = true - )); - - --- update service type to UnityCatalog - update db service entity -UPDATE dbservice_entity de -SET json = jsonb_set( - jsonb_set( - de.json #- '{serviceType}', - '{serviceType}', - '"UnityCatalog"' - ) #- '{connection,config,type}', - '{connection,config,type}', - '"UnityCatalog"' - ) -WHERE de.serviceType = 'Databricks' - AND (de.json #>> '{connection,config,useUnityCatalog}')::bool = True -; - --- remove `useUnityCatalog` flag from service connection details of databricks -UPDATE dbservice_entity de -SET json = json #- '{connection,config,useUnityCatalog}' -WHERE de.serviceType IN ('Databricks','UnityCatalog'); diff --git a/bootstrap/sql/migrations/native/1.3.0/mysql/schemaChanges.sql b/bootstrap/sql/migrations/native/1.3.0/mysql/schemaChanges.sql index c740727616b..21cc7fd81a8 100644 --- a/bootstrap/sql/migrations/native/1.3.0/mysql/schemaChanges.sql +++ b/bootstrap/sql/migrations/native/1.3.0/mysql/schemaChanges.sql @@ -46,3 +46,89 @@ where name = 'OpenMetadata' -- Clean old test connections TRUNCATE automations_workflow; + +-- update service type to UnityCatalog - update database entity +UPDATE database_entity de +SET de.json = JSON_INSERT( + JSON_REMOVE(de.json, '$.serviceType'), + '$.serviceType', + 'UnityCatalog' + ) +where id in ( +select toId from entity_relationship er +where + fromEntity = 'databaseService' + and toEntity = 'database' + and fromId in ( + select id from dbservice_entity dbe + where + serviceType = 'Databricks' + and JSON_EXTRACT( + dbe.json, '$.connection.config.useUnityCatalog' + ) = true + )); + + +-- update service type to UnityCatalog - update database schema entity +UPDATE database_schema_entity dse +SET dse.json = JSON_INSERT( + JSON_REMOVE(dse.json, '$.serviceType'), + '$.serviceType', + 'UnityCatalog' + ) +where JSON_EXTRACT(dse.json, '$.database.id') in ( +select toId from entity_relationship er +where + fromEntity = 'databaseService' + and toEntity = 'database' + and fromId in ( + select id from dbservice_entity dbe + where + serviceType = 'Databricks' + and JSON_EXTRACT( + dbe.json, '$.connection.config.useUnityCatalog' + ) = true + )); + + +-- update service type to UnityCatalog - update table entity +UPDATE table_entity te +SET te.json = JSON_INSERT( + JSON_REMOVE(te.json, '$.serviceType'), + '$.serviceType', + 'UnityCatalog' + ) +where JSON_EXTRACT(te.json, '$.database.id') in ( +select toId from entity_relationship er +where + fromEntity = 'databaseService' + and toEntity = 'database' + and fromId in ( + select id from dbservice_entity dbe + where + serviceType = 'Databricks' + and JSON_EXTRACT( + dbe.json, '$.connection.config.useUnityCatalog' + ) = true + )); + + +-- update service type to UnityCatalog - update db service entity +UPDATE dbservice_entity de +SET de.json = JSON_INSERT( + JSON_REMOVE(de.json, '$.connection.config.type'), + '$.connection.config.type', + 'UnityCatalog' + ),de.json = JSON_INSERT( + JSON_REMOVE(de.json, '$.serviceType'), + '$.serviceType', + 'UnityCatalog' + ) +WHERE de.serviceType = 'Databricks' + AND JSON_EXTRACT(de.json, '$.connection.config.useUnityCatalog') = True +; + +-- remove `useUnityCatalog` flag from service connection details of databricks +UPDATE dbservice_entity de +SET de.json = JSON_REMOVE(de.json, '$.connection.config.useUnityCatalog') +WHERE de.serviceType IN ('Databricks','UnityCatalog'); diff --git a/bootstrap/sql/migrations/native/1.3.0/postgres/schemaChanges.sql b/bootstrap/sql/migrations/native/1.3.0/postgres/schemaChanges.sql index 5d2490c4861..13d387face8 100644 --- a/bootstrap/sql/migrations/native/1.3.0/postgres/schemaChanges.sql +++ b/bootstrap/sql/migrations/native/1.3.0/postgres/schemaChanges.sql @@ -62,3 +62,85 @@ where name = 'OpenMetadata' -- Clean old test connections TRUNCATE automations_workflow; + +-- update service type to UnityCatalog - update database entity +UPDATE database_entity de +SET json = jsonb_set( + json #- '{serviceType}', + '{serviceType}', + '"UnityCatalog"', + true + ) +where id in ( +select toId from entity_relationship er +where + fromEntity = 'databaseService' + and toEntity = 'database' + and fromId in ( + select id from dbservice_entity dbe + where + serviceType = 'Databricks' + and (dbe.json #>> '{connection,config,useUnityCatalog}')::bool = true + )); + + +-- update service type to UnityCatalog - update database schema entity +UPDATE database_schema_entity dse +SET json = jsonb_set( + json #- '{serviceType}', + '{serviceType}', + '"UnityCatalog"', + true + ) +where json #>> '{database,id}' in ( +select toId from entity_relationship er +where + fromEntity = 'databaseService' + and toEntity = 'database' + and fromId in ( + select id from dbservice_entity dbe + where + serviceType = 'Databricks' + and (dbe.json #>> '{connection,config,useUnityCatalog}')::bool = true + )); + +-- update service type to UnityCatalog - update table entity +UPDATE table_entity te +SET json = jsonb_set( + json #- '{serviceType}', + '{serviceType}', + '"UnityCatalog"', + true + ) +where json #>> '{database,id}' in ( +select toId from entity_relationship er +where + fromEntity = 'databaseService' + and toEntity = 'database' + and fromId in ( + select id from dbservice_entity dbe + where + serviceType = 'Databricks' + and (dbe.json #>> '{connection,config,useUnityCatalog}')::bool = true + )); + + +-- update service type to UnityCatalog - update db service entity +UPDATE dbservice_entity de +SET json = jsonb_set( + jsonb_set( + de.json #- '{serviceType}', + '{serviceType}', + '"UnityCatalog"' + ) #- '{connection,config,type}', + '{connection,config,type}', + '"UnityCatalog"' + ) +WHERE de.serviceType = 'Databricks' + AND (de.json #>> '{connection,config,useUnityCatalog}')::bool = True +; + +-- remove `useUnityCatalog` flag from service connection details of databricks +UPDATE dbservice_entity de +SET json = json #- '{connection,config,useUnityCatalog}' +WHERE de.serviceType IN ('Databricks','UnityCatalog');