X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=sql%2FPg-upgrade2%2Fcp_greeting_migration.pl;h=176516572fbe8064e3d1e3068434a74778eda1e0;hb=0e0ff15052f7cb7ed1a2b04235a8a217da97a183;hp=46fa43885f644b785ca8b0313eafccaf5b2bf014;hpb=8f64093b4d58bd4bd72cd7465b7e402ad949eaf1;p=kivitendo-erp.git diff --git a/sql/Pg-upgrade2/cp_greeting_migration.pl b/sql/Pg-upgrade2/cp_greeting_migration.pl index 46fa43885..176516572 100644 --- a/sql/Pg-upgrade2/cp_greeting_migration.pl +++ b/sql/Pg-upgrade2/cp_greeting_migration.pl @@ -38,11 +38,11 @@ sub query_result { while (my $row = $sth2->fetchrow_hashref()) { if ($main::form->{"gender_$i"} eq "f" ) { - $mchecked = ""; - $fchecked = "checked"; + $mchecked = ""; + $fchecked = "checked"; } else { - $mchecked = "checked"; - $fchecked = ""; + $mchecked = "checked"; + $fchecked = ""; }; $gender_table .= "{cp_id}\"> $row->{cp_givenname} $row->{cp_name} $row->{cp_title} $row->{cp_greeting} \n"; @@ -85,9 +85,26 @@ sub print_question { print $main::form->parse_html_template("dbupgrade/cp_greeting_update_form"); } +sub alter_schema_only { + my $sqlcode = <do($sqlcode); +} + sub do_update { # main function + # Do not ask the user anything if there are no entries in the + # contacts table. + my ($data_exists) = $dbh->selectrow_array("SELECT * FROM contacts LIMIT 1"); + if (!$data_exists) { + alter_schema_only(); + return 1; + } + # first of all check if gender.sql was already run and thus cp_gender exists # if it exists there is no need for this update anymore, so return # without doing anything