From 289fdb053e46690409ddf2d688bbe5b3cb466a9b Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Mon, 11 Nov 2024 15:20:03 +0000 Subject: [PATCH] Bug 34355: DB schemas and atomicupdate Signed-off-by: Andrew Fuerste Henry Signed-off-by: Nick Clemens --- .../bug_34355-add_marc_order_accounts.pl | 43 +++++++++++++++++++ installer/data/mysql/kohastructure.sql | 26 +++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + 3 files changed, 70 insertions(+) create mode 100755 installer/data/mysql/atomicupdate/bug_34355-add_marc_order_accounts.pl diff --git a/installer/data/mysql/atomicupdate/bug_34355-add_marc_order_accounts.pl b/installer/data/mysql/atomicupdate/bug_34355-add_marc_order_accounts.pl new file mode 100755 index 00000000000..f0a5f2ab216 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_34355-add_marc_order_accounts.pl @@ -0,0 +1,43 @@ +use Modern::Perl; + +return { + bug_number => "34355", + description => "Add a table to allow creation of MARC order accounts and a syspref to activate it.", + up => sub { + my ($args) = @_; + my ($dbh, $out) = @$args{qw(dbh out)}; + + unless( TableExists('marc_order_accounts') ) { + $dbh->do(q{ + CREATE TABLE `marc_order_accounts` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier and primary key', + `description` varchar(250) NOT NULL COMMENT 'description of this account', + `vendor_id` int(11) DEFAULT NULL COMMENT 'vendor id for this account', + `budget_id` int(11) DEFAULT NULL COMMENT 'budget id for this account', + `download_directory` mediumtext DEFAULT NULL COMMENT 'download directory for this account', + `matcher_id` int(11) DEFAULT NULL COMMENT 'the id of the match rule used (matchpoints.matcher_id)', + `overlay_action` varchar(50) DEFAULT NULL COMMENT 'how to handle duplicate records', + `nomatch_action` varchar(50) DEFAULT NULL COMMENT 'how to handle records where no match is found', + `item_action` varchar(50) DEFAULT NULL COMMENT 'what to do with item records', + `parse_items` tinyint(1) DEFAULT NULL COMMENT 'should items be parsed', + `record_type` varchar(50) DEFAULT NULL COMMENT 'type of record in the file', + `encoding` varchar(50) DEFAULT NULL COMMENT 'file encoding', + PRIMARY KEY (`id`), + CONSTRAINT `marc_ordering_account_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `marc_ordering_account_ibfk_2` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + }); + + say $out "Added new table 'marc_order_accounts'"; + } else { + say $out "Table 'marc_order_accounts' already exists"; + } + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('MarcOrderingAutomation', '0', 'NULL', 'Enables automatic order line creation from MARC records', 'YesNo'); + } + ); + + }, +}; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 4c938daf8e1..793ce731f79 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4479,6 +4479,32 @@ CREATE TABLE `marc_modification_templates` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `marc_order_accounts` +-- + +DROP TABLE IF EXISTS `marc_order_accounts`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `marc_order_accounts` ( + `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier and primary key', + `description` varchar(250) NOT NULL COMMENT 'description of this account', + `vendor_id` int(11) DEFAULT NULL COMMENT 'vendor id for this account', + `budget_id` int(11) DEFAULT NULL COMMENT 'budget id for this account', + `download_directory` mediumtext DEFAULT NULL COMMENT 'download directory for this account', + `matcher_id` int(11) DEFAULT NULL COMMENT 'the id of the match rule used (matchpoints.matcher_id)', + `overlay_action` varchar(50) DEFAULT NULL COMMENT 'how to handle duplicate records', + `nomatch_action` varchar(50) DEFAULT NULL COMMENT 'how to handle records where no match is found', + `item_action` varchar(50) DEFAULT NULL COMMENT 'what to do with item records', + `parse_items` tinyint(1) DEFAULT NULL COMMENT 'should items be parsed', + `record_type` varchar(50) DEFAULT NULL COMMENT 'type of record in the file', + `encoding` varchar(50) DEFAULT NULL COMMENT 'file encoding', + PRIMARY KEY (`id`), + CONSTRAINT `marc_ordering_account_ibfk_1` FOREIGN KEY (`vendor_id`) REFERENCES `aqbooksellers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `marc_ordering_account_ibfk_2` FOREIGN KEY (`budget_id`) REFERENCES `aqbudgets` (`budget_id`) ON DELETE CASCADE ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `marc_overlay_rules` -- diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index b6a8c385ec6..f49557be9c7 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -398,6 +398,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('MarcFieldForModifierName','',NULL,'Where to store the name of the record''s last modifier','Free'), ('MarcFieldsToOrder','',NULL,'Set the mapping values for a new order line created from a MARC record in a staged file. In a YAML format.','textarea'), ('MarcItemFieldsToOrder','',NULL,'Set the mapping values for new item records created from a MARC record in a staged file. In a YAML format.','textarea'), +('MarcOrderingAutomation','0',NULL,'Enables automatic order line creation from MARC records','YesNo'), ('MARCOrgCode','OSt','','Define MARC Organization Code for MARC21 records - http://www.loc.gov/marc/organizations/orgshome.html','free'), ('MARCOverlayRules','0',NULL,'Use the MARC record overlay rules system to decide what actions to take for each field when modifying records.','YesNo'), ('MarkLostItemsAsReturned','batchmod,moredetail,cronjob,additem,pendingreserves,onpayment','claim_returned|batchmod|moredetail|cronjob|additem|pendingreserves|onpayment','Mark items as returned when flagged as lost','multiple'), -- 2.39.3 (Apple Git-146)