X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/865ea676d6394b4fb7e675866812248eeedd5beb..1f0d7da266e23a443c47aaa2dbab844e6be50ee4:/SL/DBUpgrade2.pm diff --git a/SL/DBUpgrade2.pm b/SL/DBUpgrade2.pm index 5c8280b2c..fea216800 100644 --- a/SL/DBUpgrade2.pm +++ b/SL/DBUpgrade2.pm @@ -7,6 +7,7 @@ use List::MoreUtils qw(any); use SL::Common; use SL::DBUpgrade2::Base; use SL::DBUtils; +use SL::System::Process; use strict; @@ -26,7 +27,7 @@ sub init { $params{path_suffix} ||= ''; $params{schema} ||= ''; - $params{path} ||= "sql/Pg-upgrade2" . $params{path_suffix}; + $params{path} ||= SL::System::Process->exe_dir . "/sql/Pg-upgrade2" . $params{path_suffix}; map { $self->{$_} = $params{$_} } keys %params; @@ -97,12 +98,17 @@ sub parse_dbupdate_controls { _control_error($form, $file_name, sprintf($locale->text("Missing 'description' field."))) ; } + delete @{$control}{qw(depth applied)}; + + my @unknown_keys = grep { !m{^ (?: depends | description | file | ignore | locales | may_fail | priority | tag ) $}x } keys %{ $control }; + if (@unknown_keys) { + _control_error($form, $file_name, sprintf($locale->text("Unknown control fields: #1", join(' ', sort({ lc $a cmp lc $b } @unknown_keys))))); + } + $control->{"priority"} *= 1; $control->{"priority"} ||= 1000; $control->{"file"} = $file; - delete @{$control}{qw(depth applied)}; - $all_controls{$control->{"tag"}} = $control; close(IN); @@ -290,8 +296,12 @@ sub process_perl_script { sub process_file { my ($self, $dbh, $filename, $version_or_control) = @_; - return $filename =~ m/sql$/ ? $self->process_query( $dbh, $filename, $version_or_control) - : $self->process_perl_script($dbh, $filename, $version_or_control); + my $result = $filename =~ m/sql$/ ? $self->process_query( $dbh, $filename, $version_or_control) + : $self->process_perl_script($dbh, $filename, $version_or_control); + + $::lxdebug->log_time("DB upgrade script '${filename}' finished"); + + return $result; } sub unapplied_upgrade_scripts { @@ -337,6 +347,8 @@ sub apply_admin_dbupgrade_scripts { print $self->{form}->parse_html_template("dbupgrade/header", { dbname => $::auth->{DB_config}->{db} }); + $::lxdebug->log_time("DB upgrades commencing"); + foreach my $control (@unapplied_scripts) { $::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); print $self->{form}->parse_html_template("dbupgrade/upgrade_message2", $control); @@ -344,6 +356,8 @@ sub apply_admin_dbupgrade_scripts { $self->process_file($dbh, "sql/Pg-upgrade2-auth/$control->{file}", $control); } + $::lxdebug->log_time("DB upgrades finished"); + print $self->{form}->parse_html_template("dbupgrade/footer", { is_admin => 1 }) if $called_from_admin; return 1; @@ -609,7 +623,7 @@ The global C object. =back A Perl script can actually implement queries that fail while -continueing the process by handling the transaction itself, e.g. with +continuing the process by handling the transaction itself, e.g. with the following function: sub do_query {