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

(-)a/installer/data/mysql/atomicupdate/bug_28854.pl (+48 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
        my ($lost_val) = $dbh->selectrow_array( "SELECT MAX(authorised_value) FROM authorised_values WHERE category = 'LOST'", {} );
25
        $lost_val++;
26
27
        $dbh->do(qq{
28
           INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('LOST',$lost_val,'Missing from bundle')
29
        });
30
        say $out "Missing from bundle LOST AV added";
31
32
        my ($nfl_val) = $dbh->selectrow_array( "SELECT MAX(authorised_value) FROM authorised_values WHERE category = 'NOT_LOAN'", {} );
33
        $nfl_val++;
34
35
        $dbh->do(qq{
36
           INSERT INTO authorised_values (category,authorised_value,lib) VALUES ('NOT_LOAN',$nfl_val,'Added to bundle')
37
        });
38
        say $out "Added to bundle NOT_LOAN AV added";
39
40
        $dbh->do(qq{
41
            INSERT IGNORE INTO systempreferences( `variable`, `value`, `options`, `explanation`, `type` )
42
            VALUES
43
              ( 'BundleLostValue', $lost_val, '', 'Sets the LOST AV value that represents "Missing from bundle" as a lost value', 'Free' ),
44
              ( 'BundleNotLoanValue', $nfl_val, '', 'Sets the NOT_LOAN AV value that represents "Added to bundle" as a not for loan value', 'Free')
45
        });
46
        say $out "System preferences added and set";
47
    }
48
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +17 lines)
Lines 3173-3178 CREATE TABLE `items` ( Link Here
3173
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3173
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3174
/*!40101 SET character_set_client = @saved_cs_client */;
3174
/*!40101 SET character_set_client = @saved_cs_client */;
3175
3175
3176
--
3177
-- Table structure for table item_bundles
3178
--
3179
3180
DROP TABLE IF EXISTS `item_bundles`;
3181
/*!40101 SET @saved_cs_client     = @@character_set_client */;
3182
/*!40101 SET character_set_client = utf8 */;
3183
CREATE TABLE `item_bundles` (
3184
  `item` int(11) NOT NULL,
3185
  `host` int(11) NOT NULL,
3186
  PRIMARY KEY (`host`, `item`),
3187
  UNIQUE KEY `item_bundles_uniq_1` (`item`),
3188
  CONSTRAINT `item_bundles_ibfk_1` FOREIGN KEY (`item`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE,
3189
  CONSTRAINT `item_bundles_ibfk_2` FOREIGN KEY (`host`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
3190
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3191
/*!40101 SET character_set_client = @saved_cs_client */;
3192
3176
--
3193
--
3177
-- Table structure for table `items_last_borrower`
3194
-- Table structure for table `items_last_borrower`
3178
--
3195
--
3179
- 

Return to bug 28854