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

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

Return to bug 35539