From 0b15c5e2cc5d5a84b062c5c5738fe54ab5df98ab 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 Signed-off-by: Mark Tompsett Signed-off-by: Kyle M Hall --- 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 719e6b2bf7..416518364e 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 @@ -491,6 +498,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 2bf6319cae..fcf4d27dfa 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -13897,29 +13897,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.39.5