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 3174-3181 CREATE TABLE `aqorders` ( -- information related to the basket line items Link Here
3174
  `sort1_authcat` varchar(10) default NULL,
3174
  `sort1_authcat` varchar(10) default NULL,
3175
  `sort2_authcat` varchar(10) default NULL,
3175
  `sort2_authcat` varchar(10) default NULL,
3176
  `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
3176
  `uncertainprice` tinyint(1), -- was this price uncertain (1 for yes, 0 for no)
3177
  `claims_count` int(11) default 0, -- count of claim letters generated
3178
  `claimed_date` date default NULL, -- last date a claim was generated
3179
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
3177
  `subscriptionid` int(11) default NULL, -- links this order line to a subscription (subscription.subscriptionid)
3180
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
3178
  parent_ordernumber int(11) default NULL, -- ordernumber of parent order line, or same as ordernumber if no parent
3181
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
3179
  `orderstatus` varchar(16) default 'new', -- the current status for this line item. Can be 'new', 'ordered', 'partial', 'complete' or 'cancelled'
Lines 3240-3245 CREATE TABLE aqorders_transfers ( Link Here
3240
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
3238
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
3241
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3239
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3242
3240
3241
--
3242
-- Table structure for table aqorders_claims
3243
--
3244
3245
DROP TABLE IF EXISTS aqorders_claims;
3246
CREATE TABLE aqorders_claims (
3247
    id int(11) AUTO_INCREMENT,
3248
    ordernumber INT(11) NOT NULL,
3249
    claimed_on TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
3250
    PRIMARY KEY (id),
3251
    CONSTRAINT aqorders_claims_ibfk_1 FOREIGN KEY (ordernumber) REFERENCES aqorders (ordernumber) ON DELETE CASCADE ON UPDATE CASCADE
3252
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
3243
3253
3244
--
3254
--
3245
-- Table structure for table `transport_cost`
3255
-- Table structure for table `transport_cost`
3246
- 

Return to bug 24161