From bd5350e11b50eb275d97b13cc65508fc69175a27 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 28 Oct 2022 22:15:40 +0000 Subject: [PATCH] Bug 32030: Add users to licenses - DB Signed-off-by: Martin Renvoize Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/atomicupdate/erm.pl | 18 ++++++++++-------- installer/data/mysql/kohastructure.sql | 14 ++++++++------ .../data/mysql/mandatory/auth_val_cat.sql | 6 +++--- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/installer/data/mysql/atomicupdate/erm.pl b/installer/data/mysql/atomicupdate/erm.pl index 108bbf0595..5f4475ca22 100755 --- a/installer/data/mysql/atomicupdate/erm.pl +++ b/installer/data/mysql/atomicupdate/erm.pl @@ -70,27 +70,29 @@ return { }); } - unless ( TableExists('erm_agreement_user_roles') ) { + unless ( TableExists('erm_user_roles') ) { $dbh->do(q{ - CREATE TABLE `erm_agreement_user_roles` ( - `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', + CREATE TABLE `erm_user_roles` ( + `agreement_id` INT(11) NULL COMMENT 'link to the agreement', + `license_id` INT(11) NULL COMMENT 'link to the license', `user_id` INT(11) NOT NULL COMMENT 'link to the user', `role` VARCHAR(80) NOT NULL COMMENT 'role of the user', - CONSTRAINT `erm_agreement_users_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `erm_agreement_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `erm_user_roles_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `erm_user_roles_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `erm_user_roles_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; }); } $dbh->do(q{ INSERT IGNORE INTO authorised_value_categories (category_name, is_system) VALUES - ('ERM_AGREEMENT_USER_ROLES', 1) + ('ERM_USER_ROLES', 1) }); $dbh->do(q{ INSERT IGNORE INTO authorised_values (category, authorised_value, lib) VALUES - ('ERM_AGREEMENT_USER_ROLES', 'librarian', 'ERM librarian'), - ('ERM_AGREEMENT_USER_ROLES', 'subject_specialist', 'Subject specialist') + ('ERM_USER_ROLES', 'librarian', 'ERM librarian'), + ('ERM_USER_ROLES', 'subject_specialist', 'Subject specialist') }); unless ( TableExists('erm_licenses') ) { diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 259d029b6e..472ce166a8 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2811,16 +2811,18 @@ CREATE TABLE `erm_agreement_periods` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- --- Table structure for table `erm_agreement_user_roles` +-- Table structure for table `erm_user_roles` -- -DROP TABLE IF EXISTS `erm_agreement_user_roles`; -CREATE TABLE `erm_agreement_user_roles` ( - `agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', +DROP TABLE IF EXISTS `erm_user_roles`; +CREATE TABLE `erm_user_roles` ( + `agreement_id` INT(11) NULL COMMENT 'link to the agreement', + `license_id` INT(11) NULL COMMENT 'link to the license', `user_id` INT(11) NOT NULL COMMENT 'link to the user', `role` VARCHAR(80) NOT NULL COMMENT 'role of the user', - CONSTRAINT `erm_agreement_users_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `erm_agreement_users_ibfk_2` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE + CONSTRAINT `erm_user_roles_ibfk_1` FOREIGN KEY (`agreement_id`) REFERENCES `erm_agreements` (`agreement_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `erm_user_roles_ibfk_2` FOREIGN KEY (`license_id`) REFERENCES `erm_licenses` (`license_id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `erm_user_roles_ibfk_3` FOREIGN KEY (`user_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- diff --git a/installer/data/mysql/mandatory/auth_val_cat.sql b/installer/data/mysql/mandatory/auth_val_cat.sql index 533b84a389..4162f94f13 100644 --- a/installer/data/mysql/mandatory/auth_val_cat.sql +++ b/installer/data/mysql/mandatory/auth_val_cat.sql @@ -79,7 +79,7 @@ VALUES ('ERM_AGREEMENT_STATUS', 1), ('ERM_AGREEMENT_CLOSURE_REASON', 1), ('ERM_AGREEMENT_RENEWAL_PRIORITY', 1), - ('ERM_AGREEMENT_USER_ROLES', 1), + ('ERM_USER_ROLES', 1), ('ERM_LICENSE_TYPE', 1), ('ERM_LICENSE_STATUS', 1), ('ERM_AGREEMENT_LICENSE_STATUS', 1), @@ -98,8 +98,8 @@ VALUES ('ERM_AGREEMENT_RENEWAL_PRIORITY', 'for_review', 'For review'), ('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_USER_ROLES', 'librarian', 'ERM librarian'), + ('ERM_USER_ROLES', 'subject_specialist', 'Subject specialist'), ('ERM_LICENSE_TYPE', 'local', 'Local'), ('ERM_LICENSE_TYPE', 'consortial', 'Consortial'), ('ERM_LICENSE_TYPE', 'national', 'National'), -- 2.39.5