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

(-)a/installer/data/mysql/atomicupdate/bug_35539.pl (-1 / +64 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
use Koha::Installer::Output qw(say_warning say_failure say_success say_info);
3
4
return {
5
    bug_number  => "35539",
6
    description => "Remove unused columns from 'categories' table",
7
    up          => sub {
8
        my ($args) = @_;
9
        my ( $dbh, $out ) = @$args{qw(dbh out)};
10
11
        if ( column_exists( 'categories', 'bulk' ) ) {
12
            my ($bulkdata) = $dbh->selectrow_array(
13
                q|
14
                SELECT bulk FROM categories;
15
            |
16
            );
17
            if ($bulkdata) {
18
                say_warning(
19
                    $out,
20
                    "Data was found in 'bulk' column in 'categories' table. Please remove this data and run the update again."
21
                );
22
            } else {
23
                $dbh->do("ALTER TABLE categories DROP COLUMN bulk");
24
                say_info( $out, "Removed 'bulk' column from 'categories' table" );
25
            }
26
        }
27
28
        if ( column_exists( 'categories', 'finetype' ) ) {
29
            my ($bulkdata) = $dbh->selectrow_array(
30
                q|
31
                SELECT finetype FROM categories;
32
            |
33
            );
34
            if ($bulkdata) {
35
                say_warning(
36
                    $out,
37
                    "Data was found in 'finetype' column in 'categories' table. Please remove this data and run the update again."
38
                );
39
40
            } else {
41
                $dbh->do("ALTER TABLE categories DROP COLUMN finetype");
42
                say_info( $out, "Removed 'finetype' column from 'categories' table" );
43
            }
44
        }
45
46
        if ( column_exists( 'categories', 'issuelimit' ) ) {
47
            my ($bulkdata) = $dbh->selectrow_array(
48
                q|
49
                SELECT issuelimit FROM categories;
50
            |
51
            );
52
            if ($bulkdata) {
53
                say_warning(
54
                    $out,
55
                    "Data was found in 'issuelimit' column in 'categories' table. Please remove this data and run the update again."
56
                );
57
            } else {
58
                $dbh->do("ALTER TABLE categories DROP COLUMN issuelimit");
59
                say_info( $out, "Removed 'issuelimit' column from 'categories' table" );
60
            }
61
        }
62
        say_info( $out, "Bug 35539: All done." );
63
    },
64
};

Return to bug 35539