Bug 34355: DB schemas and atomicupdate

Signed-off-by: Andrew Fuerste Henry <andrewfh@dubcolib.org>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Matt Blenkinsop 2024-07-31 13:02:50 +00:00 committed by Katrin Fischer
parent bc884904e2
commit 30431cdebb
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
3 changed files with 70 additions and 0 deletions

View File

@ -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');
}
);
},
};

View File

@ -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`
--

View File

@ -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'),