From ba314adfcdbea1292c18e33ec03bbb9b518f62ff Mon Sep 17 00:00:00 2001 From: Martin Stenberg Date: Mon, 26 Oct 2015 18:22:35 +0100 Subject: [PATCH] Bug 14957: Database changes --- .../bug_14957-marc-permissions-syspref.sql | 3 +++ .../atomicupdate/bug_14957-marc-permissions.sql | 31 ++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 installer/data/mysql/atomicupdate/bug_14957-marc-permissions-syspref.sql create mode 100644 installer/data/mysql/atomicupdate/bug_14957-marc-permissions.sql diff --git a/installer/data/mysql/atomicupdate/bug_14957-marc-permissions-syspref.sql b/installer/data/mysql/atomicupdate/bug_14957-marc-permissions-syspref.sql new file mode 100644 index 0000000..d697fc3 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14957-marc-permissions-syspref.sql @@ -0,0 +1,3 @@ +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('MARCPermissions','0','','Use the MARC permissions system to decide what actions to take for each field when modifying records.','YesNo'); +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('MARCPermissionsLog','0','','Write MARC permissions rule evaluations to the system log when applying rules for MARC field modifications.','YesNo'); +INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('MARCPermissionsCorrectionSimilarity','90','','New field value is considered a correction if it is similar to the old to the specified percentage.','Integer'); diff --git a/installer/data/mysql/atomicupdate/bug_14957-marc-permissions.sql b/installer/data/mysql/atomicupdate/bug_14957-marc-permissions.sql new file mode 100644 index 0000000..ffbc633 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_14957-marc-permissions.sql @@ -0,0 +1,31 @@ +DROP TABLE IF EXISTS `marc_permissions`; +DROP TABLE IF EXISTS `marc_permissions_modules`; + +CREATE TABLE `marc_permissions_modules` ( + `id` int(11) NOT NULL auto_increment, + `name` varchar(24) NOT NULL, + `description` varchar(255), + `specificity` int(11) NOT NULL DEFAULT 0, -- higher specificity will override rules with lower specificity + PRIMARY KEY(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + +-- a couple of useful default filter modules +-- these are used in various scripts, so don't remove them if you don't know +-- what you're doing. +-- New filter modules can be added here when needed +INSERT INTO `marc_permissions_modules` VALUES(NULL, 'source', 'source from where modification request was sent', 0); +INSERT INTO `marc_permissions_modules` VALUES(NULL, 'category', 'categorycode of user who requested modification', 1); +INSERT INTO `marc_permissions_modules` VALUES(NULL, 'borrower', 'borrowernumber of user who requested modification', 2); + +CREATE TABLE `marc_permissions` ( + `id` int(11) NOT NULL auto_increment, + `tagfield` varchar(255) NOT NULL, -- can be regexe, so need > 3 chars + `tagsubfield` varchar(255) DEFAULT NULL, -- can be regex, so need > 1 char + `module` int(11) NOT NULL, + `filter` varchar(255) NOT NULL, + `on_existing` ENUM('skip', 'overwrite', 'add', 'add_or_correct') DEFAULT NULL, + `on_new` ENUM('skip', 'add') DEFAULT NULL, + `on_removed` ENUM('skip', 'remove') DEFAULT NULL, + PRIMARY KEY(`id`), + CONSTRAINT `marc_permissions_ibfk1` FOREIGN KEY (`module`) REFERENCES `marc_permissions_modules` (`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- 2.1.4