OpenMetadata/bootstrap/sql/org.postgresql.Driver/v009__create_db_connection_info.sql
Cristian Calugaru 3f61c3e05d
Issue 9064 - New Object Store Service and Container models (#10283)
* First cut of the store service model

* Second cut of the store service model

* reverted accidental rename of property

* Third version for the object container schema definition.

* final draft version for container and object store service related entities

* final first draft of api's and entities for the object store service and container

* formatting

* removed test file

* formatting

* test fixes

* formatting

* more fixed tests

* fixed tests, addressed PR comments

* added type for object store connections

* addressed PR comments

* formatting

* renamed objectstoreservice to service in schemas. Changed type to fullyQualifiedEntityName in createContainer schema
2023-02-24 16:34:08 -08:00

53 lines
2.1 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 #- '{connection,config,classificationName}' where serviceType in ('BigQuery');
-- migrate ingestAllDatabases in postgres
UPDATE dbservice_entity de2
SET json = JSONB_SET(
json || JSONB_SET(json,'{connection,config}', json#>'{connection,config}'||
jsonb_build_object('database',
(SELECT 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'::jsonb
)
WHERE de2.serviceType = 'Postgres'
AND 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') STORED NOT NULL,
serviceType VARCHAR(256) GENERATED ALWAYS AS (json ->> 'serviceType') STORED NOT NULL,
json JSONB NOT NULL,
updatedAt BIGINT GENERATED ALWAYS AS ((json ->> 'updatedAt')::bigint) STORED NOT NULL,
updatedBy VARCHAR(256) GENERATED ALWAYS AS (json ->> 'updatedBy') STORED NOT NULL,
deleted BOOLEAN GENERATED ALWAYS AS ((json ->> 'deleted')::boolean) STORED,
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') STORED NOT NULL,
json JSONB NOT NULL,
updatedAt BIGINT GENERATED ALWAYS AS ((json ->> 'updatedAt')::bigint) STORED NOT NULL,
updatedBy VARCHAR(256) GENERATED ALWAYS AS (json ->> 'updatedBy') STORED NOT NULL,
deleted BOOLEAN GENERATED ALWAYS AS ((json ->> 'deleted')::boolean) STORED,
PRIMARY KEY (id),
UNIQUE (fullyQualifiedName)
);