X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=scripts%2Fdbupgrade2_tool.pl;h=97e8e3f77e86a8734fe1088d9d4dbc354fc7f790;hb=8a149188fed60abbd8741050c7394c5f156656dc;hp=a9054aaff94e495225175819f14c6773841b2a62;hpb=e055700faea1906bea6c03184ba4516b57cac887;p=kivitendo-erp.git diff --git a/scripts/dbupgrade2_tool.pl b/scripts/dbupgrade2_tool.pl index a9054aaff..97e8e3f77 100755 --- a/scripts/dbupgrade2_tool.pl +++ b/scripts/dbupgrade2_tool.pl @@ -12,6 +12,7 @@ BEGIN { use strict; +use warnings; use utf8; use English '-no_match_vars'; @@ -44,7 +45,7 @@ my ($opt_list, $opt_tree, $opt_rtree, $opt_nodeps, $opt_graphviz, $opt_help); my ($opt_user, $opt_apply, $opt_applied, $opt_format, $opt_test_utf8); my ($opt_dbhost, $opt_dbport, $opt_dbname, $opt_dbuser, $opt_dbpassword); -our (%myconfig, $form, $user, $auth, $locale, $controls); +our (%myconfig, $form, $user, $auth, $locale, $controls, $dbupgrader); sub show_help { my $help_text = <<"END_HELP" @@ -111,7 +112,7 @@ sub calc_rev_depends { } sub dump_list { - my @sorted_controls = sort_dbupdate_controls($controls); + my @sorted_controls = $dbupgrader->sort_dbupdate_controls; print "LIST VIEW\n\n" . "number tag depth priority\n"; @@ -140,7 +141,7 @@ sub dump_tree { calc_rev_depends(); - my @sorted_controls = sort_dbupdate_controls($controls); + my @sorted_controls = $dbupgrader->sort_dbupdate_controls; foreach my $control (@sorted_controls) { dump_node($control->{tag}, "") unless (@{ $control->{rev_depends} }); @@ -164,7 +165,7 @@ sub dump_tree_reverse { calc_rev_depends(); - my @sorted_controls = sort_dbupdate_controls($controls); + my @sorted_controls = $dbupgrader->sort_dbupdate_controls; foreach my $control (@sorted_controls) { last if ($control->{depth} > 1); @@ -197,7 +198,8 @@ sub dump_graphviz { foreach my $c (values %{ $controls }) { $ranks{$c->{depth}} ||= []; - my ($pre, $post) = ('node [fillcolor=lightgray] ', 'node [fillcolor=white] ') if (!scalar @{ $c->{rev_depends} }); + my ($pre, $post) = @{ $c->{rev_depends} } ? ('')x2 : + (map "node [fillcolor=$_] ", qw(lightgray white)); push @{ $ranks{$c->{"depth"}} }, qq|${pre}"$c->{tag}"; ${post}|; } @@ -207,10 +209,10 @@ sub dump_graphviz { } foreach my $c (values %{ $controls }) { - print OUT "$c->{tag};\n"; + print OUT qq|"$c->{tag}";\n|; foreach my $d (@{ $c->{depends} }) { - print OUT "$c->{tag} -> $d;\n"; + print OUT qq|"$c->{tag}" -> "$d";\n|; } } @@ -275,9 +277,9 @@ sub apply_upgrade { print "Applying upgrade $control->{file}\n"; if ($file_type eq "sql") { - $user->process_query($form, $dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control); + $dbupgrader->process_query($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control); } else { - $user->process_perl_script($form, $dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control); + $dbupgrader->process_perl_script($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control); } } @@ -359,8 +361,8 @@ sub build_upgrade_order { ####### ####### -$form = Form->new(); -$locale = Locale->new("de"); +$locale = Locale->new; +$form = Form->new; ####### ####### @@ -386,7 +388,8 @@ GetOptions("list" => \$opt_list, show_help() if ($opt_help); -$controls = parse_dbupdate_controls($form, "Pg"); +$dbupgrader = SL::DBUpgrade2->new(form => $form, dbdriver => 'Pg'); +$controls = $dbupgrader->parse_dbupdate_controls->{all_controls}; dump_list() if ($opt_list); dump_tree() if ($opt_tree);