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

(-)a/installer/data/mysql/atomicupdate/bug_24161.perl (+36 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
    unless ( TableExists( 'aqorders_claims' ) ) {
4
        $dbh->do(q|
5
            CREATE TABLE aqorders_claims (
6
                id int(11) AUTO_INCREMENT,
7
                ordernumber INT(11) NOT NULL,
8
                claimed_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
9
                PRIMARY KEY (id),
10
                CONSTRAINT aqorders_claims_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE
11
            ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci
12
        |);
13
14
        my $orders = $dbh->selectall_arrayref(q|
15
            SELECT ordernumber, claims_count, claimed_date
16
            FROM aqorders
17
            WHERE claims_count > 0
18
        |, { Slice => {} });
19
        my $insert_claim_sth = $dbh->prepare(q|
20
            INSERT INTO aqorders_claims (ordernumber, claimed_on)
21
            VALUES (?,?)
22
        |);
23
24
        for my $order ( @$orders ) {
25
            for my $claim (1..$order->{claims_count}) {
26
                $insert_claim_sth->execute($order->{ordernumber}, $order->{claimed_on});
27
            }
28
        }
29
30
        $dbh->do(q|ALTER TABLE aqorders DROP COLUMN claims_count, DROP COLUMN claimed_date|);
31
    }
32
33
    # Always end with this (adjust the bug info)
34
    SetVersion( $DBversion );
35
    print "Upgrade to $DBversion done (Bug 24161 - Add new join table aqorders_claims to keep track of claims)\n";
36
}
(-)a/installer/data/mysql/kohastructure.sql (-3 / +12 lines)
Lines 3203-3210 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
3203
  `sort1_authcat` varchar(10) default NULL,
3203
  `sort1_authcat` varchar(10) default NULL,
3204
  `sort2_authcat` varchar(10) default NULL,
3204
  `sort2_authcat` varchar(10) default NULL,
3205
  `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
3205
  `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
3206
  `claims_count` int(11) default 0, -- count of claim letters generated
3207
  `claimed_date` date default NULL, -- last date a claim was generated
3208
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
3206
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
3209
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
3207
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
3210
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
3208
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
Lines 3269-3274 CREATE TABLE aqorders_transfers ( Link Here
3269
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
3267
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
3270
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3268
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3271
3269
3270
--
3271
-- Table structure for table aqorders_claims
3272
--
3273
3274
DROP TABLE IF EXISTS aqorders_claims;
3275
CREATE TABLE aqorders_claims (
3276
    id int(11) AUTO_INCREMENT,
3277
    ordernumber INT(11) NOT NULL,
3278
    claimed_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
3279
    PRIMARY KEY (id),
3280
    CONSTRAINT aqorders_claims_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE
3281
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
3272
3282
3273
--
3283
--
3274
-- Table structure for table `transport_cost`
3284
-- Table structure for table `transport_cost`
3275
- 

Return to bug 24161