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

(-)a/installer/data/mysql/db_revs/220600041.pl (-1 / +9 lines)
Lines 6-15 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
        # Count bad records (expecting zero..)
10
        my ( $cnt ) = $dbh->selectrow_array(q{
11
            SELECT COUNT(issue_id) FROM issues
12
            LEFT JOIN borrowers USING (borrowernumber)
13
            LEFT JOIN items USING (itemnumber)
14
            WHERE items.itemnumber IS NULL OR borrowers.borrowernumber IS NULL });
15
        $dbh->do('SET FOREIGN_KEY_CHECKS=0');
9
        $dbh->do(q{
16
        $dbh->do(q{
10
            ALTER TABLE issues
17
            ALTER TABLE issues
11
                MODIFY COLUMN borrowernumber int(11) NOT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
18
                MODIFY COLUMN borrowernumber int(11) NOT NULL COMMENT 'foreign key, linking this to the borrowers table for the patron this item was checked out to',
12
                MODIFY COLUMN itemnumber int(11) NOT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out'
19
                MODIFY COLUMN itemnumber int(11) NOT NULL COMMENT 'foreign key, linking this to the items table for the item that was checked out'
13
        });
20
        });
21
        $dbh->do('SET FOREIGN_KEY_CHECKS=1');
22
        say $out "WARNING: Your issues table contains $cnt records with invalid borrowernumber or itemnumber. Please correct/remove them." if $cnt;
14
    },
23
    },
15
};
24
};
16
- 

Return to bug 32399