X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=sql%2FPg-upgrade2%2Fdefaults_posting_config.pl;h=32aa23f753833da4ad1f1e95fff6c3e54d06c40f;hb=381f15f561199cb035f1bb9d7721362a0fc4c0b7;hp=dd033d43c62c501bafbda1ec4480f95bf1af317f;hpb=16df30aaca2c8d4173f1ea76be206ef5a23e69c9;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/defaults_posting_config.pl b/sql/Pg-upgrade2/defaults_posting_config.pl
index dd033d43c..32aa23f75 100644
--- a/sql/Pg-upgrade2/defaults_posting_config.pl
+++ b/sql/Pg-upgrade2/defaults_posting_config.pl
@@ -1,49 +1,35 @@
# @tag: defaults_posting_config
# @description: Einstellung, ob und wann Zahlungen änderbar sind, vom Config-File in die DB verlagern.
# @depends: release_2_7_0
-# @charset: utf-8
+package SL::DBUpgrade2::defaults_posting_config;
-use utf8;
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 do_update {
+sub run {
+ my ($self) = @_;
# this query will fail if column already exist (new database)
- do_query(qq|ALTER TABLE defaults ADD COLUMN payments_changeable integer NOT NULL DEFAULT 0|, 1);
+ $self->db_query(qq|ALTER TABLE defaults ADD COLUMN payments_changeable integer NOT NULL DEFAULT 0|, may_fail => 1);
# check current configuration and set default variables accordingly, so that
- # Lx-Office behaviour isn't changed by this update
+ # kivitendo behaviour isn't changed by this update
# if payments_changeable is not set in config set it to 0
my $payments_changeable = 0;
- if ($::lx_office_conf{features}->{payments_changeable} == 1 ) {
- $payments_changeable = 1;
- } elsif ($::lx_office_conf{features}->{payments_changeable} == 2 ) {
- $payments_changeable = 2;
+ if (defined $::lx_office_conf{features}{payments_changeable}) {
+ if ($::lx_office_conf{features}->{payments_changeable} == 1 ) {
+ $payments_changeable = 1;
+ } elsif ($::lx_office_conf{features}->{payments_changeable} == 2 ) {
+ $payments_changeable = 2;
+ }
}
my $update_column = "UPDATE defaults SET payments_changeable = '$payments_changeable';";
- do_query($update_column);
+ $self->db_query($update_column);
return 1;
}
-return do_update();
-
+1;