From 93c405365bb4d50c20c56bea3b1dae047943596e Mon Sep 17 00:00:00 2001 From: Ayush Shah Date: Mon, 3 Jul 2023 15:16:30 +0530 Subject: [PATCH] Add Airflow Migrations for IAM RDS connection (#12259) * Add Migrations * Add not null * Resolve comments --- .../v013__create_db_connection_info.sql | 16 +++++++++++++++- .../v013__create_db_connection_info.sql | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v013__create_db_connection_info.sql b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v013__create_db_connection_info.sql index 1409de95656..d8996aef14a 100644 --- a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v013__create_db_connection_info.sql +++ b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v013__create_db_connection_info.sql @@ -344,4 +344,18 @@ SET json = JSON_INSERT( ) ) ) -WHERE name = 'tableCustomSQLQuery'; \ No newline at end of file +WHERE name = 'tableCustomSQLQuery'; + +-- Modify migrations for service connection of airflow to move password under authType if +-- Connection Type as Mysql or Postgres + +UPDATE pipeline_service_entity +SET json = JSON_INSERT( + JSON_REMOVE(json, '$.connection.config.connection.password'), + '$.connection.config.connection.authType', + JSON_OBJECT(), + '$.connection.config.connection.authType.password', + JSON_EXTRACT(json, '$.connection.config.connection.password')) +where serviceType = 'Airflow' +AND JSON_EXTRACT(json, '$.connection.config.connection.type') in ('Postgres', 'Mysql') +AND JSON_EXTRACT(json, '$.connection.config.connection.password') IS NOT NULL; diff --git a/bootstrap/sql/org.postgresql.Driver/v013__create_db_connection_info.sql b/bootstrap/sql/org.postgresql.Driver/v013__create_db_connection_info.sql index ce43694f1ae..431d2a337eb 100644 --- a/bootstrap/sql/org.postgresql.Driver/v013__create_db_connection_info.sql +++ b/bootstrap/sql/org.postgresql.Driver/v013__create_db_connection_info.sql @@ -177,3 +177,18 @@ set json = jsonb_set( '[{"name":"sqlExpression","displayName":"SQL Expression","description":"SQL expression to run against the table","dataType":"STRING","required":"true"},{"name":"strategy","displayName":"Strategy","description":"Strategy to use to run the custom SQL query (i.e. `SELECT COUNT()` or `SELECT (defaults to ROWS)","dataType":"ARRAY","optionValues":["ROWS","COUNT"],"required":false},{"name":"threshold","displayName":"Threshold","description":"Threshold to use to determine if the test passes or fails (defaults to 0).","dataType":"NUMBER","required":false}]' ) where name = 'tableCustomSQLQuery'; + +-- Modify migrations for service connection of airflow to move password under authType if +-- Connection Type as Mysql or Postgres + +UPDATE pipeline_service_entity +SET json = jsonb_set( +json #-'{connection,config,connection,password}', +'{connection,config,connection,authType}', +jsonb_build_object('password',json#>'{connection,config,connection,password}') +) +WHERE serviceType = 'Airflow' +and json#>'{connection,config,connection,type}' IN ('"Mysql"', '"Postgres"') +and json#>'{connection,config,connection,password}' is not null; + + \ No newline at end of file