From 7cb5dee2751b73c00436bbd95b14a4da967bda13 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Thu, 20 Jul 2023 13:27:02 +0200 Subject: [PATCH 1/4] improved handling of column community_id (Postgres) --- ...ption_add_dspace_object_ids_of_communities.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql new file mode 100644 index 000000000000..93a75307aaa7 --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql @@ -0,0 +1,15 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +----------------------------------------------------------------------------------- +-- add community UUIDs to dspace_object_ids (in community subscriptions) +-- remove column community_id afterwards +----------------------------------------------------------------------------------- + +UPDATE subscription SET dspace_object_id = (SELECT uuid FROM community WHERE community_id = subscription.community_id) WHERE community_id IS NOT NULL; +ALTER TABLE subscription DROP COLUMN community_id; From 3a5124baa72711ded228bebedc79c6e943de8897 Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Thu, 20 Jul 2023 13:32:38 +0200 Subject: [PATCH 2/4] improved handling of column community_id (H2) --- ...ption_add_dspace_object_ids_of_communities.sql | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql new file mode 100644 index 000000000000..93a75307aaa7 --- /dev/null +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql @@ -0,0 +1,15 @@ +-- +-- The contents of this file are subject to the license and copyright +-- detailed in the LICENSE and NOTICE files at the root of the source +-- tree and available online at +-- +-- http://www.dspace.org/license/ +-- + +----------------------------------------------------------------------------------- +-- add community UUIDs to dspace_object_ids (in community subscriptions) +-- remove column community_id afterwards +----------------------------------------------------------------------------------- + +UPDATE subscription SET dspace_object_id = (SELECT uuid FROM community WHERE community_id = subscription.community_id) WHERE community_id IS NOT NULL; +ALTER TABLE subscription DROP COLUMN community_id; From e5a0703a19b6210d9d6fd93e8b30b8039566006d Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Thu, 20 Jul 2023 13:45:17 +0200 Subject: [PATCH 3/4] add "IF EXISTS" clause --- ...07.20__subscription_add_dspace_object_ids_of_communities.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql index 93a75307aaa7..a38ba0c971a4 100644 --- a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/h2/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql @@ -12,4 +12,4 @@ ----------------------------------------------------------------------------------- UPDATE subscription SET dspace_object_id = (SELECT uuid FROM community WHERE community_id = subscription.community_id) WHERE community_id IS NOT NULL; -ALTER TABLE subscription DROP COLUMN community_id; +ALTER TABLE subscription DROP COLUMN IF EXISTS community_id; From 8cba71912b6be61e513df198f78d06fd01bf763f Mon Sep 17 00:00:00 2001 From: Sascha Szott Date: Thu, 20 Jul 2023 13:45:47 +0200 Subject: [PATCH 4/4] add "IF EXISTS" clause --- ...07.20__subscription_add_dspace_object_ids_of_communities.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql index 93a75307aaa7..a38ba0c971a4 100644 --- a/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql +++ b/dspace-api/src/main/resources/org/dspace/storage/rdbms/sqlmigration/postgres/V7.6_2023.07.20__subscription_add_dspace_object_ids_of_communities.sql @@ -12,4 +12,4 @@ ----------------------------------------------------------------------------------- UPDATE subscription SET dspace_object_id = (SELECT uuid FROM community WHERE community_id = subscription.community_id) WHERE community_id IS NOT NULL; -ALTER TABLE subscription DROP COLUMN community_id; +ALTER TABLE subscription DROP COLUMN IF EXISTS community_id;