From 36cd32d14cd2f03cb8043a5412456bfd8ce6d41e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 3 May 2022 15:03:18 +0200 Subject: [PATCH] Bug 32030: ERM - License - DB fix atomic 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 | 25 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 17 +++++++++++++ .../data/mysql/mandatory/auth_val_cat.sql | 14 +++++++++-- 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/installer/data/mysql/atomicupdate/erm.pl b/installer/data/mysql/atomicupdate/erm.pl index a8d2940579..c56e132d6f 100755 --- a/installer/data/mysql/atomicupdate/erm.pl +++ b/installer/data/mysql/atomicupdate/erm.pl @@ -93,5 +93,30 @@ return { ('ERM_AGREEMENT_USER_ROLES', 'subject_specialist', 'Subject specialist') }); + unless ( TableExists('erm_agreement_licenses') ) { + $dbh->do(q{ + CREATE TABLE `erm_agreement_licenses` ( + `agreement_license_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', + `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', + `status` VARCHAR(80) NOT NULL COMMENT 'current status of the license', + `controlling` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'is a controlling license', + `physical_location` VARCHAR(80) NOT NULL COMMENT 'physical location of the license', + `notes` mediumtext DEFAULT NULL COMMENT 'notes about this license', + `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the license', + CONSTRAINT `erm_agreement_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + PRIMARY KEY(`agreement_license_id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + } + $dbh->do(q{ + INSERT IGNORE INTO authorised_values (category, authorised_value, lib) + VALUES + ('ERM_AGREEMENT_LICENSE_STATUS', 'controlling', 'Controlling'), + ('ERM_AGREEMENT_LICENSE_STATUS', 'future', 'Future'), + ('ERM_AGREEMENT_LICENSE_STATUS', 'history', 'Historic'), + ('ERM_AGREEMENT_LICENSE_LOCATION', 'filing_cabinet', 'Filing cabinet'), + ('ERM_AGREEMENT_LICENSE_LOCATION', 'filing_cabinet', 'Cupboard'); + }); + }, }; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 046a4b4dcc..736d8918d1 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2822,6 +2822,23 @@ CREATE TABLE `erm_agreement_user_roles` ( CONSTRAINT `erm_agreement_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +-- +-- Table structure for table `erm_agreement_licenses` +-- + +DROP TABLE IF EXISTS `erm_agreement_licenses`; +CREATE TABLE `erm_agreement_licenses` ( + `agreement_license_id` INT(11) NOT NULL AUTO_INCREMENT COMMENT 'primary key', + `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', + `status` VARCHAR(80) NOT NULL COMMENT 'current status of the license', + `controlling` TINYINT(1) NOT NULL DEFAULT 0 COMMENT 'is a controlling license', + `physical_location` VARCHAR(80) NOT NULL COMMENT 'physical location of the license', + `notes` mediumtext DEFAULT NULL COMMENT 'notes about this license', + `uri` varchar(255) DEFAULT NULL COMMENT 'URI of the license', + CONSTRAINT `erm_agreement_licenses_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + PRIMARY KEY(`agreement_license_id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + -- -- Table structure for table `export_format` -- diff --git a/installer/data/mysql/mandatory/auth_val_cat.sql b/installer/data/mysql/mandatory/auth_val_cat.sql index b4b0877aec..ed9cdd56fc 100644 --- a/installer/data/mysql/mandatory/auth_val_cat.sql +++ b/installer/data/mysql/mandatory/auth_val_cat.sql @@ -79,7 +79,12 @@ VALUES ('ERM_AGREEMENT_STATUS', 1), ('ERM_AGREEMENT_CLOSURE_REASON', 1), ('ERM_AGREEMENT_RENEWAL_PRIORITY', 1), - ('ERM_AGREEMENT_USER_ROLES', 1); + ('ERM_AGREEMENT_USER_ROLES', 1), + ('ERM_LICENSE_TYPE', 1), + ('ERM_LICENSE_STATUS', 1), + ('ERM_AGREEMENT_LICENSE_STATUS', 1), + ('ERM_AGREEMENT_LICENSE_LOCATION', 1); + INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES ('ERM_AGREEMENT_STATUS', 'active', 'Active'), @@ -91,4 +96,9 @@ VALUES ('ERM_AGREEMENT_RENEWAL_PRIORITY', 'renew', 'Renew'), ('ERM_AGREEMENT_RENEWAL_PRIORITY', 'cancel', 'Cancel'), ('ERM_AGREEMENT_USER_ROLES', 'librarian', 'ERM librarian'), - ('ERM_AGREEMENT_USER_ROLES', 'subject_specialist', 'Subject specialist'); + ('ERM_AGREEMENT_USER_ROLES', 'subject_specialist', 'Subject specialist'), + ('ERM_AGREEMENT_LICENSE_STATUS', 'controlling', 'Controlling'), + ('ERM_AGREEMENT_LICENSE_STATUS', 'future', 'Future'), + ('ERM_AGREEMENT_LICENSE_STATUS', 'history', 'Historic'), + ('ERM_AGREEMENT_LICENSE_LOCATION', 'filing_cabinet', 'Filing cabinet'), + ('ERM_AGREEMENT_LICENSE_LOCATION', 'cupboard', 'Cupboard'); -- 2.39.5