From 54b95355fa5e30306f7c9116dcdbe08512c10787 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 May 2022 18:05:24 +0200 Subject: [PATCH] Bug 32030: ERM - related agreements - DB Signed-off-by: Jonathan Field Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/atomicupdate/erm.pl | 13 +++++++++++++ installer/data/mysql/kohastructure.sql | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/installer/data/mysql/atomicupdate/erm.pl b/installer/data/mysql/atomicupdate/erm.pl index 2e8d047593..ecaf4366ad 100755 --- a/installer/data/mysql/atomicupdate/erm.pl +++ b/installer/data/mysql/atomicupdate/erm.pl @@ -151,5 +151,18 @@ return { ('ERM_AGREEMENT_LICENSE_LOCATION', 'cupboard', 'Cupboard'); }); + unless ( TableExists('erm_agreement_relationships') ) { + $dbh->do(q{ + CREATE TABLE `erm_agreement_relationships` ( + `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', + `related_agreement_id` INT(11) NOT NULL COMMENT 'link to the related agreement', + `relationship` ENUM('supersedes', 'is-superseded-by', 'provides_post-cancellation_access_for', 'has-post-cancellation-access-in', 'tracks_demand-driven_acquisitions_for', 'has-demand-driven-acquisitions-in', 'has_backfile_in', 'has_frontfile_in', 'related_to') NOT NULL COMMENT 'relationship between the two agreements', + `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship', + CONSTRAINT `erm_agreement_relationships_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `erm_agreement_relationships_ibfk_2` FOREIGN KEY (`related_agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + PRIMARY KEY(`agreement_id`, `related_agreement_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } }, }; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 1a0cc55e3a..25e81c9a1c 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2856,6 +2856,21 @@ CREATE TABLE `erm_agreement_licenses` ( PRIMARY KEY(`agreement_license_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `erm_agreement_relationships` +-- + +DROP TABLE IF EXISTS `erm_agreement_relationships`; +CREATE TABLE `erm_agreement_relationships` ( + `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', + `related_agreement_id` INT(11) NOT NULL COMMENT 'link to the related agreement', + `relationship` ENUM('supersedes', 'is-superseded-by', 'provides_post-cancellation_access_for', 'has-post-cancellation-access-in', 'tracks_demand-driven_acquisitions_for', 'has-demand-driven-acquisitions-in', 'has_backfile_in', 'has_frontfile_in', 'related_to') NOT NULL COMMENT 'relationship between the two agreements', + `notes` mediumtext DEFAULT NULL COMMENT 'notes about this relationship', + CONSTRAINT `erm_agreement_relationships_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `erm_agreement_relationships_ibfk_2` FOREIGN KEY (`related_agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + PRIMARY KEY(`agreement_id`, `related_agreement_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `export_format` -- -- 2.20.1