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

(-)a/installer/data/mysql/atomicupdate/bug_28854.perl (+65 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "28854",
5
    description => "Item bundles support",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        if( !TableExists( 'item_bundles' ) ) {
11
            $dbh->do(q{
12
                CREATE TABLE `item_bundles` (
13
                  `item` int(11) NOT NULL,
14
                  `host` int(11) NOT NULL,
15
                  PRIMARY KEY (`host`, `item`),
16
                  UNIQUE KEY `item_bundles_uniq_1` (`item`),
17
                  CONSTRAINT `item_bundles_ibfk_1` FOREIGN KEY (`item`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
18
                  CONSTRAINT `item_bundles_ibfk_2` FOREIGN KEY (`host`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
19
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
20
            });
21
        }
22
        say $out "item_bundles table added";
23
24
        if( !TableExists( 'items_lost_issue' ) ) {
25
            $dbh->do(q{
26
                CREATE TABLE `items_lost_issue` (
27
                  `id` int(11) NOT NULL AUTO_INCREMENT,
28
                  `itemnumber` int(11) NOT NULL,
29
                  `issue_id` int(11) DEFAULT NULL,
30
                  `created_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
31
                  PRIMARY KEY (`id`),
32
                  UNIQUE KEY `itemnumber` (`itemnumber`),
33
                  KEY `issue_id` (`issue_id`),
34
                  CONSTRAINT `items_lost_issue_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
35
                  CONSTRAINT `items_lost_issue_ibfk_2` FOREIGN KEY (`issue_id`) REFERENCES `old_issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE
36
                ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
37
            });
38
        }
39
        say $out "items_list_issue table added";
40
    
41
        my ($lost_val) = $dbh->selectrow_array( "SELECT MAX(authorised_value) FROM authorised_values WHERE category = 'LOST'", {} );
42
        $lost_val++;
43
    
44
        $dbh->do(qq{
45
           INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOST',$lost_val,'Missing from bundle')
46
        });
47
        say $out "Missing from bundle LOST AV added";
48
    
49
        my ($nfl_val) = $dbh->selectrow_array( "SELECT MAX(authorised_value) FROM authorised_values WHERE category = 'NOT_LOAN'", {} );
50
        $nfl_val++;
51
    
52
        $dbh->do(qq{
53
           INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('NOT_LOAN',$nfl_val,'Added to bundle')
54
        });
55
        say $out "Added to bundle NOT_LOAN AV added";
56
    
57
        $dbh->do(qq{
58
            INSERT IGNORE INTO systempreferences( `variable`, `value`, `options`, `explanation`, `type` )
59
            VALUES
60
              ( 'BundleLostValue', $lost_val, '', 'Sets the LOST AV value that represents "Missing from bundle" as a lost value', 'Free' ),
61
              ( 'BundleNotLoanValue', $nfl_val, '', 'Sets the NOT_LOAN AV value that represents "Added to bundle" as a not for loan value', 'Free')
62
        });
63
        say $out "System preferences added and set";
64
    }
65
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +37 lines)
Lines 3063-3068 CREATE TABLE `items` ( Link Here
3063
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3063
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3064
/*!40101 SET character_set_client = @saved_cs_client */;
3064
/*!40101 SET character_set_client = @saved_cs_client */;
3065
3065
3066
--
3067
-- Table structure for table item_bundles
3068
--
3069
3070
DROP TABLE IF EXISTS `item_bundles`;
3071
/*!40101 SET @saved_cs_client     = @@character_set_client */;
3072
/*!40101 SET character_set_client = utf8 */;
3073
CREATE TABLE `item_bundles` (
3074
  `item` int(11) NOT NULL,
3075
  `host` int(11) NOT NULL,
3076
  PRIMARY KEY (`host`, `item`),
3077
  UNIQUE KEY `item_bundles_uniq_1` (`item`),
3078
  CONSTRAINT `item_bundles_ibfk_1` FOREIGN KEY (`item`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3079
  CONSTRAINT `item_bundles_ibfk_2` FOREIGN KEY (`host`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
3080
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3081
/*!40101 SET character_set_client = @saved_cs_client */;
3082
3066
--
3083
--
3067
-- Table structure for table `items_last_borrower`
3084
-- Table structure for table `items_last_borrower`
3068
--
3085
--
Lines 3083-3088 CREATE TABLE `items_last_borrower` ( Link Here
3083
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3100
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3084
/*!40101 SET character_set_client = @saved_cs_client */;
3101
/*!40101 SET character_set_client = @saved_cs_client */;
3085
3102
3103
--
3104
-- Table structure for table `items_lost_issue`
3105
--
3106
3107
DROP TABLE IF EXISTS `items_lost_issue`;
3108
/*!40101 SET @saved_cs_client     = @@character_set_client */;
3109
/*!40101 SET character_set_client = utf8 */;
3110
CREATE TABLE `items_lost_issue` (
3111
  `id` int(11) NOT NULL AUTO_INCREMENT,
3112
  `itemnumber` int(11) NOT NULL,
3113
  `issue_id` int(11) DEFAULT NULL,
3114
  `created_on` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
3115
  PRIMARY KEY (`id`),
3116
  UNIQUE KEY `itemnumber` (`itemnumber`),
3117
  KEY `issue_id` (`issue_id`),
3118
  CONSTRAINT `items_lost_issue_ibfk_1` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3119
  CONSTRAINT `items_lost_issue_ibfk_2` FOREIGN KEY (`issue_id`) REFERENCES `old_issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE
3120
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3121
/*!40101 SET character_set_client = @saved_cs_client */;
3122
3086
--
3123
--
3087
-- Table structure for table `items_search_fields`
3124
-- Table structure for table `items_search_fields`
3088
--
3125
--
3089
- 

Return to bug 24454