From 34f6ba77c9af8c441b16ec0c9ecbe99cb189747f Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 27 Sep 2016 08:28:09 +0100 Subject: [PATCH] Bug 17234: Move new subroutines to C4::Installer --- C4/Installer.pm | 30 ++++++++++++++++++++++++++++++ installer/data/mysql/updatedatabase.pl | 25 ------------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/C4/Installer.pm b/C4/Installer.pm index f5af971..4828462 100644 --- a/C4/Installer.pm +++ b/C4/Installer.pm @@ -26,6 +26,13 @@ use C4::Installer::PerlModules; use DBI; use Koha; +use vars qw(@ISA @EXPORT); +BEGIN { + require Exporter; + @ISA = qw( Exporter ); + push @EXPORT, qw( constraint_exists column_exists ); +}; + =head1 NAME C4::Installer @@ -488,6 +495,29 @@ sub get_file_path_from_name { } +sub constraint_exists { + my ( $table_name, $key_name ) = @_; + my $dbh = C4::Context->dbh; + my ($exists) = $dbh->selectrow_array( + qq| + SHOW INDEX FROM $table_name + WHERE key_name = ? + |, undef, $key_name + ); + return $exists; +} + +sub column_exists { + my ( $table_name, $column_name ) = @_; + my $dbh = C4::Context->dbh; + my ($exists) = $dbh->selectrow_array( + qq| + SHOW COLUMNS FROM $table_name + WHERE Field = ? + |, undef, $column_name + ); + return $exists; +} =head1 AUTHOR diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index afb199f..d8b6475 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -13192,29 +13192,4 @@ sub CheckVersion { } } -sub constraint_exists { - my ( $table_name, $key_name ) = @_; - my $dbh = C4::Context->dbh; - my ($exists) = $dbh->selectrow_array( - qq| - SHOW INDEX FROM $table_name - WHERE key_name = ? - |, undef, $key_name - ); - return $exists; -} - -sub column_exists { - my ( $table_name, $column_name ) = @_; - my $dbh = C4::Context->dbh; - my ($exists) = $dbh->selectrow_array( - qq| - SHOW COLUMNS FROM $table_name - WHERE Field = ? - |, undef, $column_name - ); - return $exists; - -} - exit; -- 2.8.1