From 474ffb445e2a54a487847dd5025c4ac3937f9661 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Agust=C3=ADn=20Moyano?= Date: Thu, 2 Feb 2023 16:57:38 -0300 Subject: [PATCH] Bug 32607: Add table and permissions This patch adds: * A new table: `record_sources`. * A new user permission: `manage_record_sources`. Record sources will contain a name and might be linked to a patron. This patron will be the one that has permission to use the assigned token through API calls. The `api_token` will be generated on Koha side on store. Signed-off-by: Tomas Cohen Arazi --- .../data/mysql/atomicupdate/bug_32607.pl | 37 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 15 ++++++++ .../data/mysql/mandatory/userpermissions.sql | 1 + 3 files changed, 53 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_32607.pl diff --git a/installer/data/mysql/atomicupdate/bug_32607.pl b/installer/data/mysql/atomicupdate/bug_32607.pl new file mode 100755 index 00000000000..cd708b6e629 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_32607.pl @@ -0,0 +1,37 @@ +use Modern::Perl; + +return { + bug_number => "32607", + description => "Add record_sources table", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + unless ( TableExists('record_sources') ) { + $dbh->do( + q{ + CREATE TABLE `record_sources` ( + `record_source_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary key for the `record_sources` table', + `name` text NOT NULL COMMENT 'User defined name for the record source', + `patron_id` int(11) NULL DEFAULT NULL COMMENT 'Internal patron identifier', + `api_token` varchar(191) NULL DEFAULT NULL COMMENT 'Generated token for identifying the record source on API interactions', + PRIMARY KEY (`record_source_id`), + CONSTRAINT `record_source_fk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + } + ); + + say $out "Added new table 'record_sources'"; + } + + $dbh->do( + q{ + INSERT IGNORE INTO permissions (module_bit, code, description) VALUES + ( 3, 'manage_record_sources', 'Manage record sources') + } + ); + + say $out "Added new permission 'manage_record_sources'"; + + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 21f6ec015c1..2bccde1f145 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -3467,6 +3467,21 @@ CREATE TABLE `import_items` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `record_sources` +-- + +DROP TABLE IF EXISTS `record_sources`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `record_sources` ( + `record_source_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Primary key for the `record_sources` table', + `name` text NOT NULL COMMENT 'User defined name for the record source', + `patron_id` int(11) NULL DEFAULT NULL COMMENT 'Internal patron identifier', + `api_token` varchar(191) NULL DEFAULT NULL COMMENT 'Generated token for identifying the record source on API interactions', + PRIMARY KEY (`record_source_id`), + CONSTRAINT `record_source_fk_1` FOREIGN KEY (`patron_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- -- Table structure for table `import_record_matches` -- diff --git a/installer/data/mysql/mandatory/userpermissions.sql b/installer/data/mysql/mandatory/userpermissions.sql index 2f84c9bc2f7..068c4b1a3f5 100644 --- a/installer/data/mysql/mandatory/userpermissions.sql +++ b/installer/data/mysql/mandatory/userpermissions.sql @@ -42,6 +42,7 @@ INSERT INTO permissions (module_bit, code, description) VALUES ( 3, 'manage_curbside_pickups', 'Manage curbside pickups'), ( 3, 'manage_search_filters', 'Manage custom search filters'), ( 3, 'manage_identity_providers', 'Manage identity providers'), + ( 3, 'manage_record_sources', 'Manage record sources'), ( 4, 'delete_borrowers', 'Delete patrons'), ( 4, 'edit_borrowers', 'Add, modify and view patron information'), ( 4, 'view_borrower_infos_from_any_libraries', 'View patron infos from any libraries'), -- 2.42.0