From 36e7ede02f3670d927a8a28e527bd16ccd511351 Mon Sep 17 00:00:00 2001 From: Paul Poulain Date: Fri, 6 Mar 2015 16:38:45 +0100 Subject: [PATCH] Bug 13068: updatedatabase improvement for developer process with this patch, the updatedatabase now checks info the atomicupdate directory. If there is some SQL 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 i'atomicupdate', 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 atomicupdate directory * run updatedatabase.pl * look at your database, what was in the .sql file must have been run Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- installer/data/mysql/updatedatabase.pl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 951060fd00..6a0f299b81 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -38,6 +38,7 @@ use C4::Context; use C4::Installer; use C4::Dates; +use File::Slurp; use MARC::Record; use MARC::File::XML ( BinaryEncoding => 'utf8' ); @@ -9902,6 +9903,21 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion ($DBversion); } +# DEVELOPER PROCESS, search for anything to execute in the db_update directory +# SEE bug 13068 +# if there is anything in the atomicupdate, read and execute it. + +opendir( my $dirh, C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate' ); +my $old_delimiter = $/; +$/ = ';'; +while (readdir $dirh) { + next unless $_ =~ /\.sql$/; # skip non SQL files + my $installer = C4::Installer->new(); + $rv = $installer->load_sql( $atomicupd->{location}. "/$file" )? 0: 1; + #Note: load_sql already warns +} + + =head1 FUNCTIONS =head2 TableExists($table) -- 2.11.0