From b66cb72378d568c1b65454fdc7af62ab24d0edb9 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Fri, 10 Oct 2014 17:30:22 +0200 Subject: [PATCH] Bug 13068, updatedatabase improvement for developer process with this patch, the updatedatabase now checks info the db_update directory. If there is something here, it's executed. Note that there is no version update, so if you run the updatedatabase script twice, you'll get an sql error probably. This patch will be very useful for sandbox testing process. When the RM pushes a patch with something in db_update, he will have to copy it into updatedatabase.pl, give it a number, and remove the file in db_update Test plan: * apply the patch * create a files with a .sql extension in the db_update directory * run updatedatabase.pl * look at your database, what was in the .sql file must have been run Signed-off-by: Brendan Gallagher --- installer/data/mysql/updatedatabase.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 9bdc033..f6937de 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -8780,6 +8780,27 @@ if ( CheckVersion($DBversion) ) { SetVersion($DBversion); } +# DEVELOPER PROCESS, search for anything to execute in the db_update directory +# SEE bug 13068 +# if there is anything in the db_update, read and execute it. + +opendir( my $dirh, C4::Context->config('intranetdir') . '/installer/data/mysql/db_update' ); +my $old_delimiter = $/; +$/ = ';'; +while (readdir $dirh) { + next unless $_ =~ /\.sql$/; # skip non SQL files + # open and read file; + open FILE, "<", C4::Context->config('intranetdir') . '/installer/data/mysql/db_update/'.$_ or die "ERROR, impossible to open $_"; + my $sql_to_execute; + while ( ) { + my $line = $_; + $line =~ s/\n//g; + $dbh->do($line) if $line; + $sql_to_execute .= $line; + } +} + + =head1 FUNCTIONS =head2 TableExists($table) -- 1.7.10.4