Bug 32030: Add users to licenses - DB
authorPedro Amorim <pjamorim91@gmail.com>
Fri, 28 Oct 2022 22:15:40 +0000 (22:15 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 8 Nov 2022 12:44:47 +0000 (09:44 -0300)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/erm.pl
installer/data/mysql/kohastructure.sql
installer/data/mysql/mandatory/auth_val_cat.sql

index 108bbf0..5f4475c 100755 (executable)
@@ -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') ) {
index 259d029..472ce16 100644 (file)
@@ -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;
 
 --
index 533b84a..4162f94 100644 (file)
@@ -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'),