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

(-)a/C4/Installer.pm (-6 / +9 lines)
Lines 632-643 sub get_file_path_from_name { Link Here
632
sub primary_key_exists {
632
sub primary_key_exists {
633
    my ( $table_name, $key_name ) = @_;
633
    my ( $table_name, $key_name ) = @_;
634
    my $dbh = C4::Context->dbh;
634
    my $dbh = C4::Context->dbh;
635
    my ($exists) = $dbh->selectrow_array(
635
    my $sql = qq| SHOW INDEX FROM $table_name WHERE key_name='PRIMARY' |;
636
        qq|
636
    my $exists;
637
        SHOW INDEX FROM $table_name
637
    if( $key_name ){
638
        WHERE key_name = 'PRIMARY' AND column_name = ?
638
        $sql .= 'AND column_name = ? ' if $key_name;
639
        |, undef, $key_name
639
        ($exists) = $dbh->selectrow_array( $sql, undef, $key_name );
640
    );
640
    } else {
641
        ($exists) = $dbh->selectrow_array( $sql, undef );
642
    }
643
641
    return $exists;
644
    return $exists;
642
}
645
}
643
646
(-)a/Koha/Import/Record.pm (-2 / +2 lines)
Lines 29-40 Koha::Import::Record - Koha Import Record Object class Link Here
29
29
30
=head1 API
30
=head1 API
31
31
32
=head2 Class methods
33
34
=head2 Internal methods
32
=head2 Internal methods
35
33
36
=head3 _type
34
=head3 _type
37
35
36
Returns name of corresponding DBIC resultset
37
38
=cut
38
=cut
39
39
40
sub _type {
40
sub _type {
(-)a/installer/data/mysql/atomicupdate/bug_26326.perl (-1 / +3 lines)
Lines 4-10 if( CheckVersion( $DBversion ) ) { Link Here
4
        primary_key_exists('import_record_matches','import_record_id') &&
4
        primary_key_exists('import_record_matches','import_record_id') &&
5
        primary_key_exists('import_record_matches','candidate_match_id')
5
        primary_key_exists('import_record_matches','candidate_match_id')
6
    ){
6
    ){
7
        $dbh->do( "ALTER TABLE import_record_matches DROP PRIMARY KEY" );
7
        if( primary_key_exists('import_record_matches' ) ){
8
            $dbh->do( "ALTER TABLE import_record_matches DROP PRIMARY KEY" );
9
        }
8
        $dbh->do( "ALTER TABLE import_record_matches ADD PRIMARY KEY (import_record_id,candidate_match_id)" );
10
        $dbh->do( "ALTER TABLE import_record_matches ADD PRIMARY KEY (import_record_id,candidate_match_id)" );
9
    }
11
    }
10
12
(-)a/t/db_dependent/Installer.t (-3 / +2 lines)
Lines 22-28 Link Here
22
# Add more tests here!!!
22
# Add more tests here!!!
23
23
24
use Modern::Perl;
24
use Modern::Perl;
25
use Test::More tests => 21;
25
use Test::More tests => 22;
26
use File::Temp qw(tempfile);
26
use File::Temp qw(tempfile);
27
use utf8;
27
use utf8;
28
28
Lines 73-79 ok( ! foreign_key_exists( 'borrowers', 'xxx' ), 'FK xxxx does not exist' ); Link Here
73
ok( unique_key_exists( 'items', 'itembarcodeidx' ), 'UNIQUE KEY itembarcodeidx exists' );
73
ok( unique_key_exists( 'items', 'itembarcodeidx' ), 'UNIQUE KEY itembarcodeidx exists' );
74
ok( ! unique_key_exists( 'borrowers', 'xxx' ), 'UNIQUE KEY xxxx does not exist' );
74
ok( ! unique_key_exists( 'borrowers', 'xxx' ), 'UNIQUE KEY xxxx does not exist' );
75
75
76
76
ok( primary_key_exists( 'borrowers' ), 'Borrowers does have a primary key on some column');
77
ok( primary_key_exists( 'borrowers', 'borrowernumber'), 'Borrowers has primary key on borrowernumber');
77
ok( primary_key_exists( 'borrowers', 'borrowernumber'), 'Borrowers has primary key on borrowernumber');
78
ok( ! primary_key_exists( 'borrowers', 'email'), 'Borrowers does not have a primary key on email');
78
ok( ! primary_key_exists( 'borrowers', 'email'), 'Borrowers does not have a primary key on email');
79
79
80
- 

Return to bug 26326