Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix upgrade (dry_run missing) #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Koha/Plugin/Com/Biblibre/PatronImport.pm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use Mojo::JSON qw(decode_json);;
use base qw(Koha::Plugins::Base);


our $VERSION = '2.1';
our $VERSION = '2.2';

our $metadata = {
name => 'Patron import',
Expand Down Expand Up @@ -519,7 +519,6 @@ sub upgrade {
}

if ($DBversion < '1.4') {
my $dbh = C4::Context->dbh;
my $exclusions_table = $self->get_qualified_table_name('exclusions_rules');
$dbh->do("ALTER TABLE $exclusions_table ADD COLUMN origin ENUM('ext', 'koha') NOT NULL AFTER name;");
}
Expand Down Expand Up @@ -589,7 +588,7 @@ sub upgrade {
");
}

if ( Koha::Plugins::Base::_version_compare($DBversion, '1.91') == -1 ) {
if ( Koha::Plugins::Base::_version_compare($DBversion, '1.91') == -1 ) {
my $runs_table = $self->get_qualified_table_name('runs');
$dbh->do("ALTER TABLE $runs_table ADD COLUMN dry_run int(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 0 AFTER error;");
}
Expand All @@ -611,6 +610,13 @@ sub upgrade {
$dbh->do("ALTER TABLE $import_table ADD COLUMN welcome_message tinyint COLLATE utf8_unicode_ci NULL;");
}

if ($DBversion < '2.2') {
my $runs_table = $self->get_qualified_table_name('runs');
unless (_column_exists($dbh, $runs_table, 'dry_run')) {
$dbh->do("ALTER TABLE $runs_table ADD COLUMN dry_run int(1) COLLATE utf8_unicode_ci NOT NULL DEFAULT 0 AFTER error;");
}
}

$self->store_data({'__INSTALLED_VERSION__' => $VERSION});

return 1;
Expand Down Expand Up @@ -701,4 +707,11 @@ sub _enable_borrowers_logs {
C4::Context->set_preference( 'BorrowersLog', $self->{BorrowersLog} );
}

sub _column_exists {
my ($dbh, $table, $column) = @_;
my $sth = $dbh->prepare("SHOW COLUMNS FROM $table LIKE ?");
$sth->execute($column);
return $sth->fetchrow_arrayref ? 1 : 0;
}

1;