From 666468187c7bcbb240e870f0a005da945fee7924 Mon Sep 17 00:00:00 2001 From: ryzheboka <25465835+ryzheboka@users.noreply.github.com> Date: Tue, 6 Aug 2024 14:39:06 +0200 Subject: [PATCH] Closes #2637 - add update scripts from 8.1 to 8.2 --- ...skana_schema_update_8.1.0_to_8.2.0_db2.sql | 19 ++++++++++++++++++ ...askana_schema_update_8.1.0_to_8.2.0_h2.sql | 20 +++++++++++++++++++ ...na_schema_update_8.1.0_to_8.2.0_oracle.sql | 19 ++++++++++++++++++ ..._schema_update_8.1.0_to_8.2.0_postgres.sql | 20 +++++++++++++++++++ .../pro/taskana/common/api/TaskanaEngine.java | 2 +- 5 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 common/taskana-common/src/main/resources/sql/db2/taskana_schema_update_8.1.0_to_8.2.0_db2.sql create mode 100644 common/taskana-common/src/main/resources/sql/h2/taskana_schema_update_8.1.0_to_8.2.0_h2.sql create mode 100644 common/taskana-common/src/main/resources/sql/oracle/taskana_schema_update_8.1.0_to_8.2.0_oracle.sql create mode 100644 common/taskana-common/src/main/resources/sql/postgres/taskana_schema_update_8.1.0_to_8.2.0_postgres.sql diff --git a/common/taskana-common/src/main/resources/sql/db2/taskana_schema_update_8.1.0_to_8.2.0_db2.sql b/common/taskana-common/src/main/resources/sql/db2/taskana_schema_update_8.1.0_to_8.2.0_db2.sql new file mode 100644 index 0000000000..ab9ec865a3 --- /dev/null +++ b/common/taskana-common/src/main/resources/sql/db2/taskana_schema_update_8.1.0_to_8.2.0_db2.sql @@ -0,0 +1,19 @@ +-- this script updates the TASKANA database schema from version 8.1.0. to version 8.2.0. +SET SCHEMA %schemaName%; + +INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) +VALUES (TASKANA_SCHEMA_VERSION_ID_SEQ.NEXTVAL, '8.2.0', CURRENT_TIMESTAMP); + +ALTER TABLE TASK + ADD COLUMN NUMBER_OF_COMMENTS INT DEFAULT 0; + +UPDATE TASK t +SET NUMBER_OF_COMMENTS = subquery.COMMENT_COUNT +FROM ( + SELECT t.ID, COUNT(tc.ID) AS COMMENT_COUNT + FROM TASK t + RIGHT OUTER JOIN TASK_COMMENT tc + ON t.ID = tc.TASK_ID + GROUP BY t.ID +) AS subquery +WHERE t.ID = subquery.ID; \ No newline at end of file diff --git a/common/taskana-common/src/main/resources/sql/h2/taskana_schema_update_8.1.0_to_8.2.0_h2.sql b/common/taskana-common/src/main/resources/sql/h2/taskana_schema_update_8.1.0_to_8.2.0_h2.sql new file mode 100644 index 0000000000..6e1b454125 --- /dev/null +++ b/common/taskana-common/src/main/resources/sql/h2/taskana_schema_update_8.1.0_to_8.2.0_h2.sql @@ -0,0 +1,20 @@ +-- this script updates the TASKANA database schema from version 8.1.0 to version 8.2.0. +SET SCHEMA %schemaName%; + +INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) +VALUES (nextval('TASKANA_SCHEMA_VERSION_ID_SEQ'), '8.2.0', CURRENT_TIMESTAMP); + +ALTER TABLE TASK + ADD COLUMN NUMBER_OF_COMMENTS INT DEFAULT 0; + +UPDATE TASK t +SET NUMBER_OF_COMMENTS = ( + SELECT COUNT(tc.ID) + FROM TASK_COMMENT tc + WHERE tc.TASK_ID = t.ID +) +WHERE EXISTS ( + SELECT 1 + FROM TASK_COMMENT tc + WHERE tc.TASK_ID = t.ID +); \ No newline at end of file diff --git a/common/taskana-common/src/main/resources/sql/oracle/taskana_schema_update_8.1.0_to_8.2.0_oracle.sql b/common/taskana-common/src/main/resources/sql/oracle/taskana_schema_update_8.1.0_to_8.2.0_oracle.sql new file mode 100644 index 0000000000..418848546c --- /dev/null +++ b/common/taskana-common/src/main/resources/sql/oracle/taskana_schema_update_8.1.0_to_8.2.0_oracle.sql @@ -0,0 +1,19 @@ +-- this script updates the TASKANA database schema from version 8.1.0 to version 8.2.0. +ALTER SESSION SET CURRENT_SCHEMA = %schemaName%; + +INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) +VALUES (nextval('TASKANA_SCHEMA_VERSION_ID_SEQ'), '8.2s.0', CURRENT_TIMESTAMP); + +ALTER TABLE TASK + ADD COLUMN NUMBER_OF_COMMENTS INT DEFAULT 0; + +UPDATE TASK t +SET NUMBER_OF_COMMENTS = subquery.COMMENT_COUNT +FROM ( + SELECT t.ID, COUNT(tc.ID) AS COMMENT_COUNT + FROM TASK t + RIGHT OUTER JOIN TASK_COMMENT tc + ON t.ID = tc.TASK_ID + GROUP BY t.ID +) AS subquery +WHERE t.ID = subquery.ID; \ No newline at end of file diff --git a/common/taskana-common/src/main/resources/sql/postgres/taskana_schema_update_8.1.0_to_8.2.0_postgres.sql b/common/taskana-common/src/main/resources/sql/postgres/taskana_schema_update_8.1.0_to_8.2.0_postgres.sql new file mode 100644 index 0000000000..833982896a --- /dev/null +++ b/common/taskana-common/src/main/resources/sql/postgres/taskana_schema_update_8.1.0_to_8.2.0_postgres.sql @@ -0,0 +1,20 @@ +-- this script updates the TASKANA database schema from version 8.1.0 to version 8.2.0. + +SET search_path = %schemaName%; + +INSERT INTO TASKANA_SCHEMA_VERSION (ID, VERSION, CREATED) +VALUES (nextval('TASKANA_SCHEMA_VERSION_ID_SEQ'), '8.2.0', CURRENT_TIMESTAMP); + +ALTER TABLE TASK + ADD COLUMN NUMBER_OF_COMMENTS INT DEFAULT 0; + +UPDATE TASK t +SET NUMBER_OF_COMMENTS = subquery.COMMENT_COUNT +FROM ( + SELECT t.ID, COUNT(tc.ID) AS COMMENT_COUNT + FROM TASK t + RIGHT OUTER JOIN TASK_COMMENT tc + ON t.ID = tc.TASK_ID + GROUP BY t.ID +) AS subquery +WHERE t.ID = subquery.ID; \ No newline at end of file diff --git a/lib/taskana-core/src/main/java/pro/taskana/common/api/TaskanaEngine.java b/lib/taskana-core/src/main/java/pro/taskana/common/api/TaskanaEngine.java index 62c19c1561..cd680edb0b 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/common/api/TaskanaEngine.java +++ b/lib/taskana-core/src/main/java/pro/taskana/common/api/TaskanaEngine.java @@ -17,7 +17,7 @@ /** The TaskanaEngine represents an overall set of all needed services. */ public interface TaskanaEngine { - String MINIMAL_TASKANA_SCHEMA_VERSION = "7.0.0"; + String MINIMAL_TASKANA_SCHEMA_VERSION = "7.1.0"; /** * Returns a {@linkplain TaskService} initialized with the current TaskanaEngine. {@linkplain