c46ff3ac3042bde89fb846d3bd042a84ea824794
[kivitendo-erp.git] / sql / Pg-upgrade2 / defaults_feature.pl
1 # @tag: defaults_feature
2 # @description: Einstellen der Feature vom Config-File in die DB verlagern.
3 # @depends: release_3_0_0
4 package SL::DBUpgrade2::defaults_feature;
5
6 use utf8;
7
8 use parent qw(SL::DBUpgrade2::Base);
9 use strict;
10
11 sub run {
12   my ($self) = @_;
13
14   # this query will fail if column already exist (new database)
15   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN webdav              boolean DEFAULT false|);
16   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN webdav_documents    boolean DEFAULT false|);
17   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN vertreter           boolean DEFAULT false|);
18   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_show_image    boolean DEFAULT true|);
19   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_listing_image boolean DEFAULT true|);
20   $self->db_query(qq|ALTER TABLE defaults ADD COLUMN parts_image_css     text    DEFAULT 'border:0;float:left;max-width:250px;margin-top:20px:margin-right:10px;margin-left:10px;'|);
21
22   # check current configuration and set default variables accordingly, so that
23   # kivitendo's behaviour isn't changed by this update
24   # if checks are not set in config set it to true
25   foreach my $check (qw(webdav vertreter parts_show_image parts_listing_image)) {
26     my $check_set = $::lx_office_conf{features}->{$check} ? 1 : 0;
27     $self->db_query("UPDATE defaults SET $check = ?", bind => [ $check_set ]);
28   }
29
30   my $update_column = "UPDATE defaults SET parts_image_css = ?";
31   $self->db_query($update_column, bind => [ $::lx_office_conf{features}->{parts_image_css} ]);
32
33   return 1;
34 }
35
36 1;