Revision acd67df0
Von Moritz Bunkus vor fast 18 Jahren hinzugefügt
scripts/dbupgrade2_tool.pl | ||
---|---|---|
sub apply_upgrade {
|
||
my $name = shift;
|
||
|
||
$form->error("Unknown dbupgrade tag '$name'") if (!$controls->{$name});
|
||
my (@order, %tags, @all_tags);
|
||
|
||
my (@order, %tags);
|
||
if ($name eq "ALL") {
|
||
calc_rev_depends();
|
||
@all_tags = map { $_->{"tag"} } grep { !@{$_->{"rev_depends"}} } values %{$controls};
|
||
|
||
build_upgrade_order($name, \@order, \%tags);
|
||
} else {
|
||
$form->error("Unknown dbupgrade tag '$name'") if (!$controls->{$name});
|
||
@all_tags = ($name);
|
||
}
|
||
|
||
foreach my $tag (@all_tags) {
|
||
build_upgrade_order($tag, \@order, \%tags);
|
||
}
|
||
|
||
my @upgradescripts = map { $controls->{$_}->{"applied"} = 0; $controls->{$_} } @order;
|
||
|
||
... | ... | |
}
|
||
$sth->finish();
|
||
|
||
my $all_applied = 1;
|
||
foreach (@upgradescripts) {
|
||
if (!$_->{"applied"}) {
|
||
$all_applied = 0;
|
||
last;
|
||
}
|
||
}
|
||
|
||
if ($all_applied) {
|
||
@upgradescripts = sort { $a->{"priority"} <=> $b->{"priority"} } grep { !$_->{"applied"} } @upgradescripts;
|
||
if (!@upgradescripts) {
|
||
print "The upgrade has already been applied.\n";
|
||
exit 0;
|
||
}
|
||
|
||
foreach my $control (@upgradescripts) {
|
||
next if ($control->{"applied"});
|
||
|
||
$control->{"file"} =~ /\.(sql|pl)$/;
|
||
my $file_type = $1;
|
||
|
||
... | ... | |
}
|
||
|
||
push @{ $order }, $name;
|
||
$tags->{$name} = 1;
|
||
}
|
||
|
||
#######
|
Auch abrufbar als: Unified diff
Eine Sonderregel für die Aktion "--apply" eingeführt: Bei "ALL" werden alle noch nicht eingespielten Upgrades aus sql/Pg-upgrade2 eingespielt.