OpenMetadata/bootstrap/sql/com.mysql.cj.jdbc.Driver/v009__create_db_connection_info.sql
Pere Miquel Brull 1e3652d35e
Fix #10382 - Test Connection Definitions, Results and Resource (#10383)
* Prep the skeleton

* Add DAO and tables

* Add Test Connection Definition Resource

* Format

* Add ResourceDescriptors & missing props

* Simplify APIs to scope for GET and LIST
2023-03-05 10:17:08 +01:00

63 lines
2.5 KiB
SQL

-- Unique constraint for user email address
ALTER TABLE user_entity
ADD UNIQUE (email);
-- Remove classificationName in BigQuery
UPDATE dbservice_entity
SET json = JSON_REMOVE(json, '$.connection.config.classificationName') where serviceType in ('BigQuery');
-- migrate ingestAllDatabases in postgres
UPDATE dbservice_entity de2
SET json = JSON_REPLACE(
JSON_INSERT(json,
'$.connection.config.database',
(select JSON_EXTRACT(json, '$.name')
from database_entity de
where id = (select er.toId
from entity_relationship er
where er.fromId = de2.id
and er.toEntity = 'database'
LIMIT 1
))
), '$.connection.config.ingestAllDatabases',
true
)
where de2.serviceType = 'Postgres'
and JSON_EXTRACT(json, '$.connection.config.database') is NULL;
-- new object store service and container entities
CREATE TABLE IF NOT EXISTS objectstore_service_entity (
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
name VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.name') NOT NULL,
serviceType VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.serviceType') NOT NULL,
json JSON NOT NULL,
updatedAt BIGINT UNSIGNED GENERATED ALWAYS AS (json ->> '$.updatedAt') NOT NULL,
updatedBy VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.updatedBy') NOT NULL,
deleted BOOLEAN GENERATED ALWAYS AS (json -> '$.deleted'),
PRIMARY KEY (id),
UNIQUE (name)
);
CREATE TABLE IF NOT EXISTS objectstore_container_entity (
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
fullyQualifiedName VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.fullyQualifiedName') NOT NULL,
json JSON NOT NULL,
updatedAt BIGINT UNSIGNED GENERATED ALWAYS AS (json ->> '$.updatedAt') NOT NULL,
updatedBy VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.updatedBy') NOT NULL,
deleted BOOLEAN GENERATED ALWAYS AS (json -> '$.deleted'),
PRIMARY KEY (id),
UNIQUE (fullyQualifiedName)
);
CREATE TABLE IF NOT EXISTS test_connection_definition (
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
name VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.name') NOT NULL,
json JSON NOT NULL,
updatedAt BIGINT UNSIGNED GENERATED ALWAYS AS (json ->> '$.updatedAt') NOT NULL,
updatedBy VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.updatedBy') NOT NULL,
deleted BOOLEAN GENERATED ALWAYS AS (json -> '$.deleted'),
PRIMARY KEY (id),
UNIQUE (name)
);