Revision acd67df0
Von Moritz Bunkus vor mehr als 17 Jahren hinzugefügt
scripts/dbupgrade2_tool.pl | ||
---|---|---|
159 | 159 |
sub apply_upgrade { |
160 | 160 |
my $name = shift; |
161 | 161 |
|
162 |
$form->error("Unknown dbupgrade tag '$name'") if (!$controls->{$name});
|
|
162 |
my (@order, %tags, @all_tags);
|
|
163 | 163 |
|
164 |
my (@order, %tags); |
|
164 |
if ($name eq "ALL") { |
|
165 |
calc_rev_depends(); |
|
166 |
@all_tags = map { $_->{"tag"} } grep { !@{$_->{"rev_depends"}} } values %{$controls}; |
|
165 | 167 |
|
166 |
build_upgrade_order($name, \@order, \%tags); |
|
168 |
} else { |
|
169 |
$form->error("Unknown dbupgrade tag '$name'") if (!$controls->{$name}); |
|
170 |
@all_tags = ($name); |
|
171 |
} |
|
172 |
|
|
173 |
foreach my $tag (@all_tags) { |
|
174 |
build_upgrade_order($tag, \@order, \%tags); |
|
175 |
} |
|
167 | 176 |
|
168 | 177 |
my @upgradescripts = map { $controls->{$_}->{"applied"} = 0; $controls->{$_} } @order; |
169 | 178 |
|
... | ... | |
182 | 191 |
} |
183 | 192 |
$sth->finish(); |
184 | 193 |
|
185 |
my $all_applied = 1; |
|
186 |
foreach (@upgradescripts) { |
|
187 |
if (!$_->{"applied"}) { |
|
188 |
$all_applied = 0; |
|
189 |
last; |
|
190 |
} |
|
191 |
} |
|
192 |
|
|
193 |
if ($all_applied) { |
|
194 |
@upgradescripts = sort { $a->{"priority"} <=> $b->{"priority"} } grep { !$_->{"applied"} } @upgradescripts; |
|
195 |
if (!@upgradescripts) { |
|
194 | 196 |
print "The upgrade has already been applied.\n"; |
195 | 197 |
exit 0; |
196 | 198 |
} |
197 | 199 |
|
198 | 200 |
foreach my $control (@upgradescripts) { |
199 |
next if ($control->{"applied"}); |
|
200 |
|
|
201 | 201 |
$control->{"file"} =~ /\.(sql|pl)$/; |
202 | 202 |
my $file_type = $1; |
203 | 203 |
|
... | ... | |
228 | 228 |
} |
229 | 229 |
|
230 | 230 |
push @{ $order }, $name; |
231 |
$tags->{$name} = 1; |
|
231 | 232 |
} |
232 | 233 |
|
233 | 234 |
####### |
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.