X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=scripts%2Fdbupgrade2_tool.pl;h=50cd27b9bbcde59acffa8e503b9e3472796545cc;hb=4f97d578f0ea0104fcd5cc63ed96622d89f6fceb;hp=45e455652708c9b026e58c869d06cfd44bb925da;hpb=008c2e1529744e195616ac2cbf7736f06a90816e;p=kivitendo-erp.git diff --git a/scripts/dbupgrade2_tool.pl b/scripts/dbupgrade2_tool.pl index 45e455652..50cd27b9b 100755 --- a/scripts/dbupgrade2_tool.pl +++ b/scripts/dbupgrade2_tool.pl @@ -73,6 +73,10 @@ dbupgrade2_tool.pl [options] for it\'s option \'-T\' are acceptable. --nodeps List all database upgrades that no other upgrade depends on + --create=tag Creates a new upgrade with the supplied tag. This + action accepts several optional other options. See + the option section for those. After creating the + upgrade file your \$EDITOR will be called with it. --apply=tag Applies the database upgrades \'tag\' and all upgrades it depends on. If \'--apply\' is used then the option \'--user\' must be used as well. @@ -87,7 +91,7 @@ dbupgrade2_tool.pl [options] and --dbpassword. --help Show this help and exit. - Options: + General Options: --user=name The name of the user configuration to use for database connectivity. --dbname=name Database connection options for the UTF-8 @@ -96,6 +100,16 @@ dbupgrade2_tool.pl [options] --dbuser=user --dbpassword=pw + Options for --create: + --type \'sql\' or \'pl\'. Defaults to sql. + --description The description field of the generated upgrade. + --encoding Encoding used for the file. Defaults to \'utf8\'. + Note: Your editor will not be told to open the file in + this encoding. + --depends Tags of upgrades which this upgrade depends upon. + Defaults to the latest stable release upgrade. + Multiple values possible. + END_HELP ; @@ -237,7 +251,7 @@ sub create_upgrade { my $filename = $params{filename}; my $dbupgrader = $params{dbupgrader}; - my $type = $params{type} || ''; + my $type = $params{type} || 'sql'; my $description = $params{description} || ''; my $encoding = $params{encoding} || 'utf-8'; my @depends = @{ $params{depends} }; @@ -270,6 +284,8 @@ sub create_upgrade { print $fh "$comment \@encoding: $encoding\n"; close $fh; + print "File $full_filename created.\n"; + system("\$EDITOR $full_filename"); exit 0; } @@ -315,6 +331,9 @@ sub apply_upgrade { exit 0; } + my $db_charset = $::lx_office_conf{system}->{dbcharset}; + $db_charset ||= Common::DEFAULT_CHARSET(); + foreach my $control (@upgradescripts) { $control->{file} =~ /\.(sql|pl)$/; my $file_type = $1; @@ -323,9 +342,9 @@ sub apply_upgrade { print "Applying upgrade $control->{file}\n"; if ($file_type eq "sql") { - $dbupgrader->process_query($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control); + $dbupgrader->process_query($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control, $db_charset); } else { - $dbupgrader->process_perl_script($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control); + $dbupgrader->process_perl_script($dbh, "sql/$form->{dbdriver}-upgrade2/$control->{file}", $control, $db_charset); } }