mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-08-30 11:56:01 +00:00

* Fix #12494: Jdbi Transactions opens a new connection per DAO causing recursive delete to not to rollback * Fix #12494: Jdbi Transactions opens a new connection per DAO causing recursive delete to not to rollback * rebase with main * Fix styling * Add jdbiUnitOfWork * Improvements for Change Event Repository and missing Annotations * Add connection commit/rollback * push schemaChange fix * Improvements for Change Event Repository and missing Annotations * Pass wrapped collectionDAO everywhere * Pass wrapped collectionDAO everywhere * Separate event handlers transactions * Fix checkstyle * Wrap PUT , POST, and DELETE in transactions * Add Patch for transactions * Add primary key to tag.id * Proxy internal @CreateSQLObjects * Fix exception handling in ManagedHandleInvocationHandler * Java typo * Update schema files * Checkstyle fix and conflicts resolve issue * Remove @JdbiUnitOfWOrk from Feed Repository * remove unnecessary @JdbiUnitOfWork annotation * Test Failures fix * Test Failures fix * Increase wait time , changeEventDAO takes time due to handle.commit() * commit change * No need to use commit in ChangeEventHandler * Add a lookup for avoiding transaction that are not started and should not be rolled back * remove JdbiUnitOfWork.java --------- Co-authored-by: Sriharsha Chintalapani <harsha@getcollate.io> Co-authored-by: Sriharsha Chintalapani <harshach@users.noreply.github.com>
86 lines
3.9 KiB
SQL
86 lines
3.9 KiB
SQL
-- column deleted not needed for entities that don't support soft delete
|
|
ALTER TABLE query_entity DROP COLUMN deleted;
|
|
ALTER TABLE event_subscription_entity DROP COLUMN deleted;
|
|
|
|
-- create domain entity table
|
|
CREATE TABLE IF NOT EXISTS domain_entity (
|
|
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
|
|
name VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.name') NOT NULL,
|
|
fqnHash VARCHAR(256) NOT NULL COLLATE ascii_bin,
|
|
json JSON NOT NULL,
|
|
updatedAt BIGINT UNSIGNED GENERATED ALWAYS AS (json ->> '$.updatedAt') NOT NULL,
|
|
updatedBy VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.updatedBy') NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE (fqnHash)
|
|
);
|
|
|
|
-- create data product entity table
|
|
CREATE TABLE IF NOT EXISTS data_product_entity (
|
|
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
|
|
name VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.name') NOT NULL,
|
|
fqnHash VARCHAR(256) NOT NULL COLLATE ascii_bin,
|
|
json JSON NOT NULL,
|
|
updatedAt BIGINT UNSIGNED GENERATED ALWAYS AS (json ->> '$.updatedAt') NOT NULL,
|
|
updatedBy VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.updatedBy') NOT NULL,
|
|
PRIMARY KEY (id),
|
|
UNIQUE (fqnHash)
|
|
);
|
|
|
|
-- create search service entity
|
|
CREATE TABLE IF NOT EXISTS search_service_entity (
|
|
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
|
|
nameHash VARCHAR(256) NOT NULL COLLATE ascii_bin,
|
|
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 (nameHash)
|
|
);
|
|
|
|
-- create search index entity
|
|
CREATE TABLE IF NOT EXISTS search_index_entity (
|
|
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
|
|
name VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.name') NOT NULL,
|
|
fqnHash VARCHAR(256) NOT NULL COLLATE ascii_bin,
|
|
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 (fqnHash)
|
|
);
|
|
|
|
-- We were hardcoding retries to 0. Since we are now using the IngestionPipeline to set them, keep existing ones to 0.
|
|
UPDATE ingestion_pipeline_entity
|
|
SET json = JSON_REPLACE(json, '$.airflowConfig.retries', 0)
|
|
WHERE JSON_EXTRACT(json, '$.airflowConfig.retries') IS NOT NULL;
|
|
|
|
|
|
-- create stored procedure entity
|
|
CREATE TABLE IF NOT EXISTS stored_procedure_entity (
|
|
id VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.id') STORED NOT NULL,
|
|
name VARCHAR(256) GENERATED ALWAYS AS (json ->> '$.name') NOT NULL,
|
|
fqnHash VARCHAR(256) NOT NULL COLLATE ascii_bin,
|
|
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 (fqnHash)
|
|
);
|
|
|
|
-- create entity extension table for table entity
|
|
CREATE TABLE IF NOT EXISTS table_entity_extension (
|
|
id VARCHAR(36) NOT NULL, -- ID of the from entity
|
|
extension VARCHAR(256) NOT NULL, -- Extension name same as entity.fieldName
|
|
jsonSchema VARCHAR(256) NOT NULL, -- Schema used for generating JSON
|
|
json JSON NOT NULL,
|
|
PRIMARY KEY (id, extension)
|
|
);
|
|
|
|
ALTER TABLE entity_relationship ADD INDEX from_entity_type_index(fromId, fromEntity), ADD INDEX to_entity_type_index(toId, toEntity);
|
|
ALTER TABLE tag DROP CONSTRAINT fqnHash, ADD CONSTRAINT UNIQUE(fqnHash), ADD PRIMARY KEY(id);
|