X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=sql%2FPg-upgrade2%2Fcp_greeting_migration.pl;h=cb2ed66cff9972f8e5b4af1c5d7ec4d1986dcc3c;hb=2da5d610ce0aeb43428de82e6b5e79acfb502628;hp=176516572fbe8064e3d1e3068434a74778eda1e0;hpb=f44251d96a55c8c561172a0b510b487447a7c4c1;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/cp_greeting_migration.pl b/sql/Pg-upgrade2/cp_greeting_migration.pl
index 176516572..cb2ed66cf 100644
--- a/sql/Pg-upgrade2/cp_greeting_migration.pl
+++ b/sql/Pg-upgrade2/cp_greeting_migration.pl
@@ -1,43 +1,30 @@
# @tag: cp_greeting_migration
# @description: Migration of cp_greeting to cp_gender
# @depends: generic_translations
+package SL::DBUpgrade2::cp_greeting_migration;
use strict;
+use utf8;
-die("This script cannot be run from the command line.") unless ($main::form);
-
-sub mydberror {
- my ($msg) = @_;
- die($dbup_locale->text("Database update error:") . " $msg " . $DBI::errstr);
-}
-
-sub do_query {
- my ($query, $may_fail) = @_;
-
- if (!$dbh->do($query)) {
- mydberror($query) unless ($may_fail);
- $dbh->rollback();
- $dbh->begin_work();
- }
-}
-
+use parent qw(SL::DBUpgrade2::Base);
sub query_result {
+ my ($self) = @_;
# list of all entries where cp_greeting is empty, meaning can't determine gender from parsing Herr/Frau/...
# this assumes cp_greeting still exists, i.e. gender.sql was not run yet
my ($gender_table, $mchecked, $fchecked);
my $sql2 = "select cp_id,cp_givenname,cp_name,cp_title,cp_greeting from contacts where not (cp_greeting ILIKE '%frau%' OR cp_greeting ILIKE '%herr%' or cp_greeting ILIKE '%mrs.%' or cp_greeting ILIKE '%miss%') ";
- my $sth2 = $dbh->prepare($sql2) or die $dbh->errstr();
- $sth2->execute() or die $dbh->errstr();
+ my $sth2 = $self->dbh->prepare($sql2) or die $self->dbh->errstr();
+ $sth2->execute() or die $self->dbh->errstr();
my $i = 1;
$gender_table .= '
";
- $main::form->{gender_table} = $gender_table;
+ $::form->{gender_table} = $gender_table;
my $title_table;
my $sql3 = "select cp_id,cp_givenname,cp_name,cp_title,cp_greeting from contacts where not ( (cp_greeting ILIKE '%frau%' OR cp_greeting ILIKE '%herr%' or cp_greeting ILIKE '%mrs.%' or cp_greeting ILIKE '%miss%')) and not (cp_greeting like ''); ";
- my $sth3 = $dbh->prepare($sql3) or die $dbh->errstr();
- $sth3->execute() or die $dbh->errstr();
+ my $sth3 = $self->dbh->prepare($sql3) or die $self->dbh->errstr();
+ $sth3->execute() or die $self->dbh->errstr();
$title_table = '