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

(-)a/installer/data/mysql/atomicupdate/bug_37954.pl (-1 / +43 lines)
Line 0 Link Here
0
- 
1
use Modern::Perl;
2
3
return {
4
    bug_number  => "37954",
5
    description => "Move holdings_barcodes setting to holdings_barcode",
6
    up          => sub {
7
        my ($args) = @_;
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
10
        my ($existing_holdings_barcode_setting) = $dbh->selectrow_array(
11
            q{
12
                SELECT COUNT(*) FROM columns_settings WHERE module='catalogue' AND page='detail' AND tablename='holdings_table' AND columnname='holdings_barcode'
13
        }
14
        );
15
        if ($existing_holdings_barcode_setting) {
16
            say $out "Settings already exist";
17
        } else {
18
            my ( $cannot_be_toggled, $is_hidden ) = $dbh->selectrow_array(
19
                q{
20
                    SELECT cannot_be_toggled,is_hidden FROM columns_settings WHERE module='catalogue' AND page='detail' AND tablename='holdings_table' AND columnname='holdings_barcodes'
21
            }
22
            );
23
24
            if ( defined $cannot_be_toggled || defined $is_hidden ) {
25
                $dbh->do(
26
                    qq{
27
                    INSERT IGNORE INTO columns_settings VALUES
28
                    ('catalogue', 'detail', 'holdings_table', 'holdings_barcode', $cannot_be_toggled, $is_hidden )
29
                }
30
                );
31
                say $out "Settings moved to holdings_barcode";
32
            } else {
33
                say $out "No settings for holdings_barcodes found";
34
            }
35
        }
36
        $dbh->do(
37
            q{
38
            DELETE FROM columns_settings WHERE module='catalogue' AND page='detail' AND tablename='holdings_table' AND columnname='holdings_barcodes'
39
        }
40
        );
41
        say $out "Removed settings for holdings_barcodes";
42
    },
43
};

Return to bug 37954