X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=sql%2FPg-upgrade2%2Fdefaults_show_bestbefore.pl;h=a7c144c4f1f111911e50ce0b1fdeeb3abf5f242b;hb=741287a80da6d42dde2b87a471ef7b6c77c8cd1f;hp=36b1882bc46ef28cf2bc989fdd26446fac328c91;hpb=16df30aaca2c8d4173f1ea76be206ef5a23e69c9;p=kivitendo-erp.git
diff --git a/sql/Pg-upgrade2/defaults_show_bestbefore.pl b/sql/Pg-upgrade2/defaults_show_bestbefore.pl
index 36b1882bc..a7c144c4f 100644
--- a/sql/Pg-upgrade2/defaults_show_bestbefore.pl
+++ b/sql/Pg-upgrade2/defaults_show_bestbefore.pl
@@ -1,36 +1,21 @@
# @tag: defaults_show_bestbefore
# @description: Einstellung, ob Mindesthaltbarkeitsdatum angezeigt wird, vom Config-File in die DB verlagern.
# @depends: release_2_7_0
-# @charset: utf-8
+package SL::DBUpgrade2::defaults_show_bestbefore;
-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 show_bestbefore boolean DEFAULT false|, 1);
+ $self->db_query(qq|ALTER TABLE defaults ADD COLUMN show_bestbefore boolean DEFAULT false|, 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 show_best_before is not set in config set it to 0
my $show_bestbefore = 0;
if ($::lx_office_conf{features}->{show_best_before}) {
@@ -38,10 +23,9 @@ sub do_update {
}
my $update_column = "UPDATE defaults SET show_bestbefore = '$show_bestbefore';";
- do_query($update_column);
+ $self->db_query($update_column);
return 1;
}
-return do_update();
-
+1;