Revision 626ec4b4
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
SL/DBUpgrade2.pm | ||
---|---|---|
272 | 272 |
} |
273 | 273 |
|
274 | 274 |
if (ref($version_or_control) eq "HASH") { |
275 |
$dbh->do("INSERT INTO schema_info (tag, login) VALUES (" . $dbh->quote($version_or_control->{"tag"}) . ", " . $dbh->quote($form->{"login"}) . ")"); |
|
275 |
$dbh->do("INSERT INTO " . $self->{schema} . "schema_info (tag, login) VALUES (" . $dbh->quote($version_or_control->{"tag"}) . ", " . $dbh->quote($form->{"login"}) . ")");
|
|
276 | 276 |
} elsif ($version_or_control) { |
277 | 277 |
$dbh->do("UPDATE defaults SET version = " . $dbh->quote($version_or_control)); |
278 | 278 |
} |
... | ... | |
331 | 331 |
|
332 | 332 |
my @all_scripts = map { $_->{applied} = 0; $_ } $self->sort_dbupdate_controls; |
333 | 333 |
|
334 |
my $query = qq|SELECT tag FROM schema_info|; |
|
334 |
my $query = qq|SELECT tag FROM | . $self->{schema} . qq|schema_info|;
|
|
335 | 335 |
my $sth = $dbh->prepare($query); |
336 | 336 |
$sth->execute || $self->{form}->dberror($query); |
337 | 337 |
while (my ($tag) = $sth->fetchrow_array()) { |
bin/mozilla/admin.pl | ||
---|---|---|
43 | 43 |
|
44 | 44 |
use SL::Auth; |
45 | 45 |
use SL::Form; |
46 |
use SL::Iconv; |
|
46 | 47 |
use SL::Mailer; |
47 | 48 |
use SL::User; |
48 | 49 |
use SL::Common; |
... | ... | |
84 | 85 |
$::auth->set_session_value('rpw', $::form->{rpw}); |
85 | 86 |
$::auth->create_or_refresh_session(); |
86 | 87 |
} |
88 |
|
|
89 |
_apply_dbupgrade_scripts(); |
|
90 |
|
|
87 | 91 |
call_sub($locale->findsub($form->{action})); |
88 | 92 |
} |
89 | 93 |
} else { |
... | ... | |
1162 | 1166 |
$form->error($locale->text('No action defined.')); |
1163 | 1167 |
} |
1164 | 1168 |
|
1169 |
sub _apply_dbupgrade_scripts { |
|
1170 |
my $dbh = $::auth->dbconnect; |
|
1171 |
my $dbdriver = 'Pg'; |
|
1172 |
my $dbupdater = SL::DBUpgrade2->new(form => $::form, dbdriver => $dbdriver, auth => 1)->parse_dbupdate_controls; |
|
1173 |
my @unapplied_scripts = $dbupdater->unapplied_upgrade_scripts($dbh); |
|
1174 |
|
|
1175 |
return if !@unapplied_scripts; |
|
1176 |
|
|
1177 |
my $db_charset = $main::dbcharset || Common::DEFAULT_CHARSET; |
|
1178 |
$form->{login} = 'admin'; |
|
1179 |
|
|
1180 |
map { $_->{description} = SL::Iconv::convert($_->{charset}, $db_charset, $_->{description}) } values %{ $dbupdater->{all_controls} }; |
|
1181 |
|
|
1182 |
$form->{title} = $::locale->text('Dataset upgrade'); |
|
1183 |
$form->header; |
|
1184 |
print $form->parse_html_template("dbupgrade/header", { dbname => $::auth->{DB_config}->{db} }); |
|
1185 |
|
|
1186 |
foreach my $control (@unapplied_scripts) { |
|
1187 |
$::lxdebug->message(LXDebug->DEBUG2(), "Applying Update $control->{file}"); |
|
1188 |
print $form->parse_html_template("dbupgrade/upgrade_message2", $control); |
|
1189 |
|
|
1190 |
$dbupdater->process_file($dbh, "sql/${dbdriver}-upgrade2-auth/$control->{file}", $control, $db_charset); |
|
1191 |
} |
|
1192 |
|
|
1193 |
print $form->parse_html_template("dbupgrade/footer", { is_admin => 1, menufile => 'admin.pl' }); |
|
1194 |
::end_of_request(); |
|
1195 |
} |
|
1196 |
|
|
1165 | 1197 |
1; |
templates/webpages/dbupgrade/footer.html | ||
---|---|---|
3 | 3 |
|
4 | 4 |
<form action="[% menufile %]"> |
5 | 5 |
|
6 |
<input type="hidden" name="action" value="display">
|
|
6 |
<input type="hidden" name="action" value="[% IF is_admin %]login[% ELSE %]display[% END %]">
|
|
7 | 7 |
|
8 | 8 |
<p><input type="submit" value="[% 'Continue' | $T8 %]"></p> |
9 | 9 |
</form> |
Auch abrufbar als: Unified diff
DB-Upgrade-Mechanismus für auth-Scripte im Verzeichnis sql/Pg-upgrade2-auth implementiert