X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=sql%2FPg-upgrade2%2Frm_whitespaces.pl;h=c63758a6e643b148dcbaf03f1011490c010b3f21;hb=da2f5aa8cea79ff0a3e1e5e88e74cbf7e9e79794;hp=51d2395ef30f24a79c4c448ef7dd67261187d767;hpb=1ee1e4294fd04bdb3593ac7c494cb80f693c3e16;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/rm_whitespaces.pl b/sql/Pg-upgrade2/rm_whitespaces.pl
index 51d2395ef..c63758a6e 100644
--- a/sql/Pg-upgrade2/rm_whitespaces.pl
+++ b/sql/Pg-upgrade2/rm_whitespaces.pl
@@ -1,53 +1,31 @@
# @tag: rm_whitespaces
# @description: Entfernt mögliche Leerzeichen am Anfang und Ende jeder Währung
# @depends: release_3_0_0
-# @charset: utf-8
+
+package SL::DBUpgrade2::rm_whitespaces;
+
+use parent qw(SL::DBUpgrade2::Base);
use utf8;
use strict;
-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 run {
+ my ($self) = @_;
-sub do_query {
- my ($query, $may_fail) = @_;
+ my $query;
- if (!$dbh->do($query)) {
- mydberror($query) unless ($may_fail);
- $dbh->rollback();
- $dbh->begin_work();
+ foreach my $table (qw(ar ap oe customer delivery_orders exchangerate vendor)){
+ $self->db_query(qq|UPDATE ${table} SET curr=BTRIM(curr)|)
}
-}
-
-
-sub do_update {
- my $query = qq|UPDATE ar SET curr = RTRIM(LTRIM(curr))|;
- do_query($query);
- $query = qq|UPDATE ap SET curr = RTRIM(LTRIM(curr))|;
- do_query($query);
- $query = qq|UPDATE oe SET curr = RTRIM(LTRIM(curr))|;
- do_query($query);
- $query = qq|UPDATE customer SET curr = RTRIM(LTRIM(curr))|;
- do_query($query);
- $query = qq|UPDATE delivery_orders SET curr = RTRIM(LTRIM(curr))|;
- do_query($query);
- $query = qq|UPDATE exchangerate SET curr = RTRIM(LTRIM(curr))|;
- do_query($query);
- $query = qq|UPDATE vendor SET curr = RTRIM(LTRIM(curr))|;
- do_query($query);
$query = qq|SELECT curr FROM defaults|;
- my ($curr) = selectrow_query($self, $dbh, $query);
+ my ($curr) = $self->dbh->selectrow_array($query);
$curr =~ s/ //g;
$query = qq|UPDATE defaults SET curr = '$curr'|;
- do_query($query);
+ $self->db_query($query);
return 1;
};
-return do_update();
+1;