From e826c98acf042f1113119fd77f2d7a108fb3cd57 Mon Sep 17 00:00:00 2001 From: Vivek Ratnavel Subramanian Date: Thu, 30 Jun 2022 00:38:24 -0700 Subject: [PATCH] Fix migration script for migrations to 0.11 (#5773) --- .../v002__create_db_connection_info.sql | 2 +- .../org.postgresql.Driver/v002__create_db_connection_info.sql | 3 +++ .../java/org/openmetadata/catalog/jdbi3/FeedRepository.java | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v002__create_db_connection_info.sql b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v002__create_db_connection_info.sql index f6ba295122b..408af2b5436 100644 --- a/bootstrap/sql/com.mysql.cj.jdbc.Driver/v002__create_db_connection_info.sql +++ b/bootstrap/sql/com.mysql.cj.jdbc.Driver/v002__create_db_connection_info.sql @@ -28,7 +28,7 @@ CREATE TABLE IF NOT EXISTS mlmodel_service_entity ( UNIQUE (name) ); -UPDATE thread_entity SET json = JSON_SET(json, '$.type', 'Conversation'); +UPDATE thread_entity SET json = JSON_SET(json, '$.type', 'Conversation', '$.reactions', JSON_ARRAY()); ALTER TABLE thread_entity ADD type VARCHAR(64) GENERATED ALWAYS AS (json ->> '$.type'), diff --git a/bootstrap/sql/org.postgresql.Driver/v002__create_db_connection_info.sql b/bootstrap/sql/org.postgresql.Driver/v002__create_db_connection_info.sql index 942d88382d5..7bafaab6c1d 100644 --- a/bootstrap/sql/org.postgresql.Driver/v002__create_db_connection_info.sql +++ b/bootstrap/sql/org.postgresql.Driver/v002__create_db_connection_info.sql @@ -30,6 +30,9 @@ CREATE TABLE IF NOT EXISTS mlmodel_service_entity ( UPDATE thread_entity SET json = jsonb_set(json, '{type}', '"Conversation"', true); +update thread_entity +SET json = jsonb_set(json, '{reactions}', '[]'::jsonb, true); + ALTER TABLE thread_entity ADD type VARCHAR(64) GENERATED ALWAYS AS (json ->> 'type') STORED NOT NULL, ADD taskId INT GENERATED ALWAYS AS ((json#>'{task,id}')::integer) STORED, diff --git a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/FeedRepository.java b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/FeedRepository.java index 56a16a14a17..333647477d5 100644 --- a/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/FeedRepository.java +++ b/catalog-rest-service/src/main/java/org/openmetadata/catalog/jdbi3/FeedRepository.java @@ -720,6 +720,7 @@ public class FeedRepository { restorePatchAttributes(original, updated); if (!updated.getReactions().isEmpty()) { + populateUserReactions(updated.getReactions()); updated .getReactions() .forEach(