}
if (ref($version_or_control) eq "HASH") {
- $dbh->do("INSERT INTO schema_info (tag, login) VALUES (" . $dbh->quote($version_or_control->{"tag"}) . ", " . $dbh->quote($form->{"login"}) . ")");
+ $dbh->do("INSERT INTO " . $self->{schema} . "schema_info (tag, login) VALUES (" . $dbh->quote($version_or_control->{"tag"}) . ", " . $dbh->quote($form->{"login"}) . ")");
} elsif ($version_or_control) {
$dbh->do("UPDATE defaults SET version = " . $dbh->quote($version_or_control));
}
my @all_scripts = map { $_->{applied} = 0; $_ } $self->sort_dbupdate_controls;
- my $query = qq|SELECT tag FROM schema_info|;
+ my $query = qq|SELECT tag FROM | . $self->{schema} . qq|schema_info|;
my $sth = $dbh->prepare($query);
$sth->execute || $self->{form}->dberror($query);
while (my ($tag) = $sth->fetchrow_array()) {
use SL::Auth;
use SL::Form;
+use SL::Iconv;
use SL::Mailer;
use SL::User;
use SL::Common;
$::auth->set_session_value('rpw', $::form->{rpw});
$::auth->create_or_refresh_session();
}
+
+ _apply_dbupgrade_scripts();
+
call_sub($locale->findsub($form->{action}));
}
} else {
$form->error($locale->text('No action defined.'));
}
+sub _apply_dbupgrade_scripts {
+ my $dbh = $::auth->dbconnect;
+ my $dbdriver = 'Pg';
+ my $dbupdater = SL::DBUpgrade2->new(form => $::form, dbdriver => $dbdriver, auth => 1)->parse_dbupdate_controls;
+ my @unapplied_scripts = $dbupdater->unapplied_upgrade_scripts($dbh);
+
+ return if !@unapplied_scripts;
+
+ my $db_charset = $main::dbcharset || Common::DEFAULT_CHARSET;
+ $form->{login} = 'admin';
+
+ map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $dbupdater->{all_controls} };
+
+ $form->{title} = $::locale->text('Dataset upgrade');
+ $form->header;
+ print $form->parse_html_template("dbupgrade/header", { dbname => $::auth->{DB_config}->{db} });
+
+ foreach my $control (@unapplied_scripts) {
+ $::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}");
+ print $form->parse_html_template("dbupgrade/upgrade_message2", $control);
+
+ $dbupdater->process_file($dbh, "sql/${dbdriver}-upgrade2-auth/$control->{file}", $control, $db_charset);
+ }
+
+ print $form->parse_html_template("dbupgrade/footer", { is_admin => 1, menufile => 'admin.pl' });
+ ::end_of_request();
+}
+
1;