_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 | superuser_privileges | 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);
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 {
return grep { !$_->{applied} } @all_scripts;
}
-sub update2_available {
- my ($self, $dbh) = @_;
-
- my @unapplied_scripts = $self->unapplied_upgrade_scripts($dbh);
-
- return !!@unapplied_scripts;
-}
-
sub apply_admin_dbupgrade_scripts {
my ($self, $called_from_admin) = @_;
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);
$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;
=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 {
Requires that the scripts have been parsed.
-=item C<update2_available $dbh>
-
-Returns trueish if at least one upgrade script hasn't been applied to
-a database yet. C<$dbh> is an open handle to the database that is
-checked.
-
-Requires that the scripts have been parsed.
-
=back
=head1 BUGS