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

(-)a/installer/data/mysql/db_revs/220600056.pl (-1 / +18 lines)
Lines 6-11 return { Link Here
6
    up => sub {
6
    up => sub {
7
        my ($args) = @_;
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
10
        # Preliminary data checks
11
        my $sql = "SELECT COUNT(*) FROM z3950servers WHERE host IS NULL";
12
        my ($cnt) = $dbh->selectrow_array($sql);
13
        if( $cnt ) { # No host is really bad data! Remove it.
14
            $dbh->do( "DELETE FROM z3950servers WHERE host IS NULL" );
15
            say $out "Found bad data in table z3950servers: removed $cnt records with host undefined";
16
        }
17
        $sql = "SELECT host FROM z3950servers WHERE syntax IS NULL OR encoding IS NULL";
18
        my $hosts = $dbh->selectcol_arrayref($sql);
19
        if( @$hosts ) { # This is bad data too. We choose a default here.
20
            $dbh->do( q|UPDATE z3950servers SET syntax = COALESCE(syntax, 'USMARC'), encoding = COALESCE(encoding, 'utf8')
21
                WHERE syntax IS NULL OR encoding IS NULL| );
22
            say $out "Corrected empty syntax or encoding for the following hosts. Please check after upgrade.";
23
            say $out "Updated hosts: ". (join ',', @$hosts);
24
        }
25
26
        # Actual dbrev
9
        $dbh->do(q{
27
        $dbh->do(q{
10
alter table z3950servers
28
alter table z3950servers
11
    change column `host` `host` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'target''s host name',
29
    change column `host` `host` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'target''s host name',
12
- 

Return to bug 30571