From 325480fb2e1e17d663ef0722e8cd7f23c7fba9c4 Mon Sep 17 00:00:00 2001
From: NiharDoshi99 <51595473+NiharDoshi99@users.noreply.github.com>
Date: Tue, 4 Apr 2023 22:45:19 +0530
Subject: [PATCH] added migration scripts for druid and postgres docs update
(#10920)
* added migration scripts for druid and postgres docs update
* postgres docs update
---
.../v009__create_db_connection_info.sql | 8 ++++++++
.../v009__create_db_connection_info.sql | 4 ++++
.../content/connectors/database/postgres/airflow.md | 10 +++++++++-
.../content/connectors/database/postgres/cli.md | 10 +++++++++-
.../content/connectors/database/postgres/index.md | 10 +++++++++-
.../locales/en-US/Database/Postgres/requirements.md | 10 +++++++++-
6 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v009__create_db_connection_info.sql b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v009__create_db_connection_info.sql
index 051dfc92c48..e99f3325229 100644
--- a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v009__create_db_connection_info.sql
+++ b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v009__create_db_connection_info.sql
@@ -134,3 +134,11 @@ CREATE TABLE IF NOT EXISTS dashboard_data_model_entity (
PRIMARY KEY (id),
UNIQUE (fullyQualifiedName)
);
+
+UPDATE dbservice_entity
+SET json = JSON_INSERT(
+ JSON_REMOVE(json, '$.connection.config.database'),
+ '$.connection.config.databaseName', JSON_EXTRACT(json, '$.connection.config.database')
+ )
+where serviceType = 'Druid'
+ and JSON_EXTRACT(json, '$.connection.config.database') is not null;
\ No newline at end of file
diff --git a/bootstrap/sql/org.postgresql.Driver/v009__create_db_connection_info.sql b/bootstrap/sql/org.postgresql.Driver/v009__create_db_connection_info.sql
index 36dcd5065a7..fd5dd7bfc29 100644
--- a/bootstrap/sql/org.postgresql.Driver/v009__create_db_connection_info.sql
+++ b/bootstrap/sql/org.postgresql.Driver/v009__create_db_connection_info.sql
@@ -138,3 +138,7 @@ CREATE TABLE IF NOT EXISTS dashboard_data_model_entity (
PRIMARY KEY (id),
UNIQUE (fullyQualifiedName)
);
+
+UPDATE dbservice_entity
+SET json = jsonb_set(json::jsonb #- '{connection,config,database}', '{connection,config,databaseName}', json#> '{connection,config,database}', true)
+WHERE servicetype = 'Druid' and json #>'{connection,config,database}' is not null;
\ No newline at end of file
diff --git a/openmetadata-docs/content/connectors/database/postgres/airflow.md b/openmetadata-docs/content/connectors/database/postgres/airflow.md
index 76e1d1fa91f..746e11fa272 100644
--- a/openmetadata-docs/content/connectors/database/postgres/airflow.md
+++ b/openmetadata-docs/content/connectors/database/postgres/airflow.md
@@ -59,10 +59,18 @@ Then, when extracting usage and lineage data, the query log duration will have n
-- For usage and lineage grant your user `pg_read_all_stats` permission.
+#### For usage and lineage grant your user required permission.
+
+ - For Postgres version 14 and above
```sql
GRANT pg_read_all_stats TO your_user;
+```
+
+ - For any other Postgres version
+
+```sql
+GRANT USAGE ON SCHEMA public TO my_user;
```
diff --git a/openmetadata-docs/content/connectors/database/postgres/cli.md b/openmetadata-docs/content/connectors/database/postgres/cli.md
index 59c4dc6cacc..ced61b5510d 100644
--- a/openmetadata-docs/content/connectors/database/postgres/cli.md
+++ b/openmetadata-docs/content/connectors/database/postgres/cli.md
@@ -59,10 +59,18 @@ Then, when extracting usage and lineage data, the query log duration will have n
-- For usage and lineage grant your user `pg_read_all_stats` permission.
+#### For usage and lineage grant your user required permission.
+
+ - For Postgres version 14 and above
```sql
GRANT pg_read_all_stats TO your_user;
+```
+
+ - For any other Postgres version
+
+```sql
+GRANT USAGE ON SCHEMA public TO my_user;
```
diff --git a/openmetadata-docs/content/connectors/database/postgres/index.md b/openmetadata-docs/content/connectors/database/postgres/index.md
index d681a58714e..b5df4c57b36 100644
--- a/openmetadata-docs/content/connectors/database/postgres/index.md
+++ b/openmetadata-docs/content/connectors/database/postgres/index.md
@@ -80,10 +80,18 @@ Then, when extracting usage and lineage data, the query log duration will have n
-- For usage and lineage grant your user `pg_read_all_stats` permission.
+#### For usage and lineage grant your user required permission.
+
+ - For Postgres version 14 and above
```sql
GRANT pg_read_all_stats TO your_user;
+```
+
+ - For any other Postgres version
+
+```sql
+GRANT USAGE ON SCHEMA public TO my_user;
```
diff --git a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Postgres/requirements.md b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Postgres/requirements.md
index b599feb0d06..c141b886021 100644
--- a/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Postgres/requirements.md
+++ b/openmetadata-ui/src/main/resources/ui/public/locales/en-US/Database/Postgres/requirements.md
@@ -22,10 +22,18 @@ Then, when extracting usage and lineage data, the query log duration will have n
-- For usage and lineage grant your user `pg_read_all_stats` permission.
+#### For usage and lineage grant your user required permission.
+
+ - For Postgres version 14 and above
```sql
GRANT pg_read_all_stats TO your_user;
+```
+
+ - For any other Postgres version
+
+```sql
+GRANT USAGE ON SCHEMA public TO my_user;
```