From acd67df07b40e953b4b3955f035801bb7eae74b9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 26 Apr 2007 15:31:25 +0000 Subject: [PATCH] =?utf8?q?Eine=20Sonderregel=20f=C3=BCr=20die=20Aktion=20"?= =?utf8?q?--apply"=20eingef=C3=BChrt:=20Bei=20"ALL"=20werden=20alle=20noch?= =?utf8?q?=20nicht=20eingespielten=20Upgrades=20aus=20sql/Pg-upgrade2=20ei?= =?utf8?q?ngespielt.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- scripts/dbupgrade2_tool.pl | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/scripts/dbupgrade2_tool.pl b/scripts/dbupgrade2_tool.pl index e936247a5..fa45848c7 100755 --- a/scripts/dbupgrade2_tool.pl +++ b/scripts/dbupgrade2_tool.pl @@ -159,11 +159,20 @@ sub dump_nodeps { 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; @@ -182,22 +191,13 @@ sub apply_upgrade { } $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; @@ -228,6 +228,7 @@ sub build_upgrade_order { } push @{ $order }, $name; + $tags->{$name} = 1; } ####### -- 2.20.1