View | Details | Raw Unified | Return to bug 14957
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_14957-marc-merge-rules-permissions.sql (-2 lines)
Lines 1-2 Link Here
1
INSERT INTO permissions (module_bit, code, description) VALUES
2
  ( 3, 'manage_marc_merge_rules', 'Manage MARC merge rules configuration');
(-)a/installer/data/mysql/atomicupdate/bug_14957-marc-merge-rules.perl (+56 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    my $sql = q{
4
      CREATE TABLE IF NOT EXISTS `marc_merge_rules_modules` (
5
        `name` varchar(127) NOT NULL,
6
        `description` varchar(255),
7
        `specificity` int(11) NOT NULL UNIQUE,
8
        PRIMARY KEY(`name`)
9
      );
10
    };
11
    $dbh->do( $sql );
12
13
    $dbh->do( "INSERT IGNORE INTO `marc_merge_rules_modules` VALUES('source', 'source from where modification request was sent', 0);" );
14
    $dbh->do( "INSERT IGNORE INTO `marc_merge_rules_modules` VALUES('category', 'categorycode of user who requested modification', 1);" );
15
    $dbh->do( "INSERT IGNORE INTO `marc_merge_rules_modules` VALUES('borrower', 'borrowernumber of user who requested modification', 2);" );
16
17
    $sql = q{
18
      CREATE TABLE IF NOT EXISTS `marc_merge_rules` (
19
        `id` int(11) NOT NULL auto_increment,
20
        `tag` varchar(255) NOT NULL, -- can be regexp, so need > 3 chars
21
        `module` varchar(127) NOT NULL,
22
        `filter` varchar(255) NOT NULL,
23
        `add` tinyint NOT NULL,
24
        `append` tinyint NOT NULL,
25
        `remove` tinyint NOT NULL,
26
        `delete` tinyint NOT NULL,
27
        PRIMARY KEY(`id`),
28
        CONSTRAINT `marc_merge_rules_ibfk1` FOREIGN KEY (`module`) REFERENCES `marc_merge_rules_modules` (`name`) ON DELETE CASCADE ON UPDATE CASCADE
29
      );
30
    };
31
    $dbh->do( $sql );
32
33
    $sql = q{
34
      INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES (
35
        'MARCMergeRules',
36
        '0',
37
        NULL,
38
        'Use the MARC merge rules system to decide what actions to take for each field when modifying records.',
39
        'YesNo'
40
      );
41
    };
42
    $dbh->do( $sql );
43
44
    $sql = q{
45
      INSERT IGNORE INTO permissions (module_bit, code, description) VALUES (
46
        3,
47
        'manage_marc_merge_rules',
48
        'Manage MARC merge rules configuration'
49
      );
50
    };
51
    $dbh->do( $sql );
52
53
    # Always end with this (adjust the bug info)
54
    SetVersion( $DBversion );
55
    print "Upgrade to $DBversion done (Bug 14957 - Write protecting MARC fields based on source of import)\n";
56
}
(-)a/installer/data/mysql/atomicupdate/bug_14957-marc-merge-rules.sql (-30 lines)
Lines 1-30 Link Here
1
DROP TABLE IF EXISTS `marc_merge_rules`;
2
DROP TABLE IF EXISTS `marc_merge_rules_modules`;
3
4
CREATE TABLE `marc_merge_rules_modules` (
5
    `name` varchar(127) NOT NULL,
6
    `description` varchar(255),
7
    `specificity` int(11) NOT NULL UNIQUE, -- higher specificity will override rules with lower specificity
8
    PRIMARY KEY(`name`)
9
);
10
11
-- a couple of useful default filter modules
12
-- these are used in various scripts, so don't remove them if you don't know
13
-- what you're doing.
14
-- New filter modules can be added here when needed
15
INSERT INTO `marc_merge_rules_modules` VALUES('source', 'source from where modification request was sent', 0);
16
INSERT INTO `marc_merge_rules_modules` VALUES('category', 'categorycode of user who requested modification', 1);
17
INSERT INTO `marc_merge_rules_modules` VALUES('borrower', 'borrowernumber of user who requested modification', 2);
18
19
CREATE TABLE IF NOT EXISTS `marc_merge_rules` (
20
    `id` int(11) NOT NULL auto_increment,
21
    `tag` varchar(255) NOT NULL, -- can be regexp, so need > 3 chars
22
    `module` varchar(127) NOT NULL,
23
    `filter` varchar(255) NOT NULL,
24
    `add` tinyint NOT NULL,
25
    `append` tinyint NOT NULL,
26
    `remove` tinyint NOT NULL,
27
    `delete` tinyint NOT NULL,
28
    PRIMARY KEY(`id`),
29
    CONSTRAINT `marc_merge_rules_ibfk1` FOREIGN KEY (`module`) REFERENCES `marc_merge_rules_modules` (`name`) ON DELETE CASCADE
30
);
(-)a/installer/data/mysql/atomicupdate/bug_14957-merge-rules-syspref.sql (-2 lines)
Line 1 Link Here
1
INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('MARCMergeRules','0','','Use the MARC merge rules system to decide what actions to take for each field when modifying records.','YesNo');
2
- 

Return to bug 14957