Bug 32030: Add users to licenses - DB

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>
This commit is contained in:
Pedro Amorim 2022-10-28 22:15:40 +00:00 committed by Tomas Cohen Arazi
parent 4d9ed4b897
commit bd5350e11b
Signed by: tomascohen
GPG key ID: 0A272EA1B2F3C15F
3 changed files with 21 additions and 17 deletions

View file

@ -70,27 +70,29 @@ return {
}); });
} }
unless ( TableExists('erm_agreement_user_roles') ) { unless ( TableExists('erm_user_roles') ) {
$dbh->do(q{ $dbh->do(q{
CREATE TABLE `erm_agreement_user_roles` ( CREATE TABLE `erm_user_roles` (
`agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', `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', `user_id` INT(11) NOT NULL COMMENT 'link to the user',
`role` VARCHAR(80) NOT NULL COMMENT 'role of 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_user_roles_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_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; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
}); });
} }
$dbh->do(q{ $dbh->do(q{
INSERT IGNORE INTO authorised_value_categories (category_name, is_system) INSERT IGNORE INTO authorised_value_categories (category_name, is_system)
VALUES VALUES
('ERM_AGREEMENT_USER_ROLES', 1) ('ERM_USER_ROLES', 1)
}); });
$dbh->do(q{ $dbh->do(q{
INSERT IGNORE INTO authorised_values (category, authorised_value, lib) INSERT IGNORE INTO authorised_values (category, authorised_value, lib)
VALUES VALUES
('ERM_AGREEMENT_USER_ROLES', 'librarian', 'ERM librarian'), ('ERM_USER_ROLES', 'librarian', 'ERM librarian'),
('ERM_AGREEMENT_USER_ROLES', 'subject_specialist', 'Subject specialist') ('ERM_USER_ROLES', 'subject_specialist', 'Subject specialist')
}); });
unless ( TableExists('erm_licenses') ) { unless ( TableExists('erm_licenses') ) {

View file

@ -2811,16 +2811,18 @@ CREATE TABLE `erm_agreement_periods` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; ) 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`; DROP TABLE IF EXISTS `erm_user_roles`;
CREATE TABLE `erm_agreement_user_roles` ( CREATE TABLE `erm_user_roles` (
`agreement_id` INT(11) NOT NULL COMMENT 'link to the agreement', `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', `user_id` INT(11) NOT NULL COMMENT 'link to the user',
`role` VARCHAR(80) NOT NULL COMMENT 'role of 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_user_roles_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_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; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
-- --

View file

@ -79,7 +79,7 @@ VALUES
('ERM_AGREEMENT_STATUS', 1), ('ERM_AGREEMENT_STATUS', 1),
('ERM_AGREEMENT_CLOSURE_REASON', 1), ('ERM_AGREEMENT_CLOSURE_REASON', 1),
('ERM_AGREEMENT_RENEWAL_PRIORITY', 1), ('ERM_AGREEMENT_RENEWAL_PRIORITY', 1),
('ERM_AGREEMENT_USER_ROLES', 1), ('ERM_USER_ROLES', 1),
('ERM_LICENSE_TYPE', 1), ('ERM_LICENSE_TYPE', 1),
('ERM_LICENSE_STATUS', 1), ('ERM_LICENSE_STATUS', 1),
('ERM_AGREEMENT_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', 'for_review', 'For review'),
('ERM_AGREEMENT_RENEWAL_PRIORITY', 'renew', 'Renew'), ('ERM_AGREEMENT_RENEWAL_PRIORITY', 'renew', 'Renew'),
('ERM_AGREEMENT_RENEWAL_PRIORITY', 'cancel', 'Cancel'), ('ERM_AGREEMENT_RENEWAL_PRIORITY', 'cancel', 'Cancel'),
('ERM_AGREEMENT_USER_ROLES', 'librarian', 'ERM librarian'), ('ERM_USER_ROLES', 'librarian', 'ERM librarian'),
('ERM_AGREEMENT_USER_ROLES', 'subject_specialist', 'Subject specialist'), ('ERM_USER_ROLES', 'subject_specialist', 'Subject specialist'),
('ERM_LICENSE_TYPE', 'local', 'Local'), ('ERM_LICENSE_TYPE', 'local', 'Local'),
('ERM_LICENSE_TYPE', 'consortial', 'Consortial'), ('ERM_LICENSE_TYPE', 'consortial', 'Consortial'),
('ERM_LICENSE_TYPE', 'national', 'National'), ('ERM_LICENSE_TYPE', 'national', 'National'),