From e22036cc092a92fa5848d2f3bf5fcc85f347ebd3 Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 20 Sep 2022 08:14:29 +0200 Subject: [PATCH] Fixes #7504 Added migration steps to delete profiler pipeline from entity relationship (#7511) * Added migration steps to delete profiler pipeline from entity relationship * Added migration to remove rows from entity_relationship with profiler pipelines * Fixed sample data TestDefinition name after renaming testDefinition * Added user_tokens table to v005 Co-authored-by: mohitdeuex --- .../v004__create_db_connection_info.sql | 9 --------- .../v005__create_db_connection_info.sql | 15 +++++++++++++++ .../v004__create_db_connection_info.sql | 11 +---------- .../v005__create_db_connection_info.sql | 15 +++++++++++++++ .../sample_data/tests/testCaseResults.json | 2 +- .../examples/sample_data/tests/testSuites.json | 4 ++-- 6 files changed, 34 insertions(+), 22 deletions(-) create mode 100644 bootstrap/sql/com.mysql.cj.jdbc.Driver/v005__create_db_connection_info.sql create mode 100644 bootstrap/sql/org.postgresql.Driver/v005__create_db_connection_info.sql diff --git a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql index c8ed7843e96..9577b4838f4 100644 --- a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql +++ b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v004__create_db_connection_info.sql @@ -116,12 +116,3 @@ DELETE FROM policy_entity; DELETE FROM field_relationship WHERE fromType IN ('role', 'policy') OR toType IN ('role', 'policy'); DELETE FROM entity_relationship WHERE fromEntity IN ('role', 'policy') OR toEntity IN ('role', 'policy'); ALTER TABLE role_entity DROP COLUMN defaultRole; - -CREATE TABLE IF NOT EXISTS user_tokens ( - token VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.token') STORED NOT NULL, - userId VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.userId') STORED NOT NULL, - tokenType VARCHAR(50) GENERATED ALWAYS AS (json ->> '$.tokenType') STORED NOT NULL, - json JSON NOT NULL, - expiryDate BIGINT UNSIGNED GENERATED ALWAYS AS (json ->> '$.expiryDate') NOT NULL, - PRIMARY KEY (token) -); diff --git a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v005__create_db_connection_info.sql b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v005__create_db_connection_info.sql new file mode 100644 index 00000000000..98632713ba3 --- /dev/null +++ b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v005__create_db_connection_info.sql @@ -0,0 +1,15 @@ +DELETE FROM entity_relationship +WHERE toEntity = 'ingestionPipeline' +AND toId NOT IN ( + SELECT DISTINCT id + FROM ingestion_pipeline_entity +); + +CREATE TABLE IF NOT EXISTS user_tokens ( + token VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.token') STORED NOT NULL, + userId VARCHAR(36) GENERATED ALWAYS AS (json ->> '$.userId') STORED NOT NULL, + tokenType VARCHAR(50) GENERATED ALWAYS AS (json ->> '$.tokenType') STORED NOT NULL, + json JSON NOT NULL, + expiryDate BIGINT UNSIGNED GENERATED ALWAYS AS (json ->> '$.expiryDate') NOT NULL, + PRIMARY KEY (token) +); \ No newline at end of file diff --git a/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql b/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql index cfec331e486..853db9264f5 100644 --- a/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql +++ b/bootstrap/sql/org.postgresql.Driver/v004__create_db_connection_info.sql @@ -110,13 +110,4 @@ DELETE FROM role_entity; DELETE FROM policy_entity; DELETE FROM field_relationship WHERE fromType IN ('role', 'policy') OR toType IN ('role', 'policy'); DELETE FROM entity_relationship WHERE fromEntity IN ('role', 'policy') OR toEntity IN ('role', 'policy'); -ALTER TABLE role_entity DROP COLUMN defaultRole; - -CREATE TABLE IF NOT EXISTS user_tokens ( - token VARCHAR(36) GENERATED ALWAYS AS (json ->> 'token') STORED NOT NULL, - userId VARCHAR(36) GENERATED ALWAYS AS (json ->> 'userId') STORED NOT NULL, - tokenType VARCHAR(50) GENERATED ALWAYS AS (json ->> 'tokenType') STORED NOT NULL, - json JSONB NOT NULL, - expiryDate BIGINT GENERATED ALWAYS AS ((json ->> 'expiryDate')::bigint) STORED NOT NULL, - PRIMARY KEY (token) -); \ No newline at end of file +ALTER TABLE role_entity DROP COLUMN defaultRole; \ No newline at end of file diff --git a/bootstrap/sql/org.postgresql.Driver/v005__create_db_connection_info.sql b/bootstrap/sql/org.postgresql.Driver/v005__create_db_connection_info.sql new file mode 100644 index 00000000000..c374c6d7856 --- /dev/null +++ b/bootstrap/sql/org.postgresql.Driver/v005__create_db_connection_info.sql @@ -0,0 +1,15 @@ +DELETE FROM entity_relationship +WHERE toEntity = 'ingestionPipeline' +AND toId NOT IN ( + SELECT DISTINCT id + FROM ingestion_pipeline_entity +); + +CREATE TABLE IF NOT EXISTS user_tokens ( + token VARCHAR(36) GENERATED ALWAYS AS (json ->> 'token') STORED NOT NULL, + userId VARCHAR(36) GENERATED ALWAYS AS (json ->> 'userId') STORED NOT NULL, + tokenType VARCHAR(50) GENERATED ALWAYS AS (json ->> 'tokenType') STORED NOT NULL, + json JSONB NOT NULL, + expiryDate BIGINT GENERATED ALWAYS AS ((json ->> 'expiryDate')::bigint) STORED NOT NULL, + PRIMARY KEY (token) +); \ No newline at end of file diff --git a/ingestion/examples/sample_data/tests/testCaseResults.json b/ingestion/examples/sample_data/tests/testCaseResults.json index 9b3f08dd36b..e72754d795a 100644 --- a/ingestion/examples/sample_data/tests/testCaseResults.json +++ b/ingestion/examples/sample_data/tests/testCaseResults.json @@ -74,7 +74,7 @@ ] }, { - "result": "columnCount should not be None for TableColumnCountToEqual", + "result": "columnCount should not be None for tableColumnCountToEqual", "testCaseStatus": "Aborted", "testResultValues": [ { diff --git a/ingestion/examples/sample_data/tests/testSuites.json b/ingestion/examples/sample_data/tests/testSuites.json index db515342413..2843e2047eb 100644 --- a/ingestion/examples/sample_data/tests/testSuites.json +++ b/ingestion/examples/sample_data/tests/testSuites.json @@ -9,7 +9,7 @@ "name": "table_column_count_equals", "description": "test the number of column in table", "entityLink": "<#E::table::sample_data.ecommerce_db.shopify.dim_address>", - "testDefinitionName": "TableColumnCountToEqual", + "testDefinitionName": "tableColumnCountToEqual", "parameterValues": [ { "name": "columnCount", @@ -21,7 +21,7 @@ "name": "table_column_count_between", "description": "test the number of column in table is between x and y", "entityLink": "<#E::table::sample_data.ecommerce_db.shopify.dim_address>", - "testDefinitionName": "TableColumnCountToBeBetween", + "testDefinitionName": "tableColumnCountToBeBetween", "parameterValues": [ { "name": "minColValue",