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

(-)a/installer/data/mysql/atomicupdate/bug_25037_convert_onsite_checkout_to_checkout_type.perl (+49 lines)
Line 0 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
3
4
    # ISSUES
5
    # Convert issues.onsite_checkout to checkout_type => 'CHECKOUT' / 'ONSITE'
6
    if ( ! column_exists( 'issues', 'checkout_type' ) ) {
7
        $dbh->do( q|
8
            ALTER TABLE issues ADD COLUMN checkout_type ENUM('CHECKOUT', 'ONSITE') NOT NULL DEFAULT 'CHECKOUT' AFTER onsite_checkout;
9
        | );
10
    }
11
    if ( column_exists( 'issues', 'onsite_checkout' ) && column_exists( 'issues', 'checkout_type' ) ) {
12
        $dbh->do( q|
13
            UPDATE issues SET checkout_type='CHECKOUT' WHERE onsite_checkout<>1;
14
        | );
15
        $dbh->do( q|
16
            UPDATE issues SET checkout_type='ONSITE' WHERE onsite_checkout=1;
17
        | );
18
    }
19
    if ( column_exists( 'issues', 'onsite_checkout' ) ) {
20
        $dbh->do( q|
21
            ALTER TABLE issues DROP COLUMN onsite_checkout;
22
        | );
23
    }
24
25
    # OLD_ISSUES
26
    # Convert old_issues.onsite_checkout to checkout_type => 'CHECKOUT' / 'ONSITE'
27
    if ( ! column_exists( 'old_issues', 'checkout_type' ) ) {
28
        $dbh->do( q|
29
            ALTER TABLE old_issues ADD COLUMN checkout_type ENUM('CHECKOUT', 'ONSITE') NOT NULL DEFAULT 'CHECKOUT' AFTER onsite_checkout;
30
        | );
31
    }
32
    if ( column_exists( 'old_issues', 'onsite_checkout' ) && column_exists( 'old_issues', 'checkout_type' ) ) {
33
        $dbh->do( q|
34
            UPDATE old_issues SET checkout_type='CHECKOUT' WHERE onsite_checkout<>1;
35
        | );
36
        $dbh->do( q|
37
            UPDATE old_issues SET checkout_type='ONSITE' WHERE onsite_checkout=1;
38
        | );
39
    }
40
    if ( column_exists( 'old_issues', 'onsite_checkout' ) ) {
41
        $dbh->do( q|
42
            ALTER TABLE old_issues DROP COLUMN onsite_checkout;
43
        | );
44
    }
45
46
    # Always end with this (adjust the bug info)
47
    SetVersion( $DBversion );
48
    print "Upgrade to $DBversion done (Bug 25037 - Convert issues.onsite_checkout to issues.checkout_type column)\n";
49
}
(-)a/installer/data/mysql/kohastructure.sql (-3 / +2 lines)
Lines 1616-1622 CREATE TABLE `issues` ( -- information related to check outs or issues Link Here
1616
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, -- automatic renewal error
1616
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, -- automatic renewal error
1617
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1617
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1618
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1618
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1619
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1619
  `checkout_type` ENUM('CHECKOUT', 'ONSITE') NOT NULL default 'CHECKOUT', -- checkout type
1620
  `note` LONGTEXT default NULL, -- issue note text
1620
  `note` LONGTEXT default NULL, -- issue note text
1621
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1621
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1622
  `noteseen` int(1) default NULL, -- describes whether checkout note has been seen 1, not been seen 0 or doesn't exist null
1622
  `noteseen` int(1) default NULL, -- describes whether checkout note has been seen 1, not been seen 0 or doesn't exist null
Lines 1648-1654 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r Link Here
1648
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, -- automatic renewal error
1648
  `auto_renew_error` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, -- automatic renewal error
1649
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1649
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1650
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1650
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1651
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1651
  `checkout_type` ENUM('CHECKOUT', 'ONSITE') NOT NULL default 'CHECKOUT', -- checkout type
1652
  `note` LONGTEXT default NULL, -- issue note text
1652
  `note` LONGTEXT default NULL, -- issue note text
1653
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1653
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1654
  `noteseen` int(1) default NULL, -- describes whether checkout note has been seen 1, not been seen 0 or doesn't exist null
1654
  `noteseen` int(1) default NULL, -- describes whether checkout note has been seen 1, not been seen 0 or doesn't exist null
1655
- 

Return to bug 25037