From: Bernd Bleßmann Date: Fri, 8 May 2020 15:03:18 +0000 (+0200) Subject: Abteilungen bei Ansprechpersonen in eigene Tabelle: DB-Upgrade und Rose X-Git-Tag: release-3.5.6.1~202 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=371ab59da0ebb21a8438cab732530e1cf5f9471c;p=kivitendo-erp.git Abteilungen bei Ansprechpersonen in eigene Tabelle: DB-Upgrade und Rose --- diff --git a/SL/DB/ContactDepartment.pm b/SL/DB/ContactDepartment.pm new file mode 100644 index 000000000..a7645b1fc --- /dev/null +++ b/SL/DB/ContactDepartment.pm @@ -0,0 +1,13 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::ContactDepartment; + +use strict; + +use SL::DB::MetaSetup::ContactDepartment; +use SL::DB::Manager::ContactDepartment; + +__PACKAGE__->meta->initialize; + +1; diff --git a/SL/DB/Helper/ALL.pm b/SL/DB/Helper/ALL.pm index 5fd1d762e..006a389db 100644 --- a/SL/DB/Helper/ALL.pm +++ b/SL/DB/Helper/ALL.pm @@ -27,6 +27,7 @@ use SL::DB::Buchungsgruppe; use SL::DB::Business; use SL::DB::Chart; use SL::DB::Contact; +use SL::DB::ContactDepartment; use SL::DB::ContactTitle; use SL::DB::CsvImportProfile; use SL::DB::CsvImportProfileSetting; diff --git a/SL/DB/Helper/Mappings.pm b/SL/DB/Helper/Mappings.pm index 6f5859642..da931f9c8 100644 --- a/SL/DB/Helper/Mappings.pm +++ b/SL/DB/Helper/Mappings.pm @@ -110,6 +110,7 @@ my %kivitendo_package_names = ( bin => 'bin', business => 'business', chart => 'chart', + contact_departments => 'contact_department', contact_titles => 'contact_title', contacts => 'contact', customer => 'customer', diff --git a/SL/DB/Manager/ContactDepartment.pm b/SL/DB/Manager/ContactDepartment.pm new file mode 100644 index 000000000..f545f650c --- /dev/null +++ b/SL/DB/Manager/ContactDepartment.pm @@ -0,0 +1,14 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::Manager::ContactDepartment; + +use strict; + +use parent qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::ContactDepartment' } + +__PACKAGE__->make_manager_methods; + +1; diff --git a/SL/DB/MetaSetup/ContactDepartment.pm b/SL/DB/MetaSetup/ContactDepartment.pm new file mode 100644 index 000000000..bba52e1c1 --- /dev/null +++ b/SL/DB/MetaSetup/ContactDepartment.pm @@ -0,0 +1,21 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::ContactDepartment; + +use strict; + +use parent qw(SL::DB::Object); + +__PACKAGE__->meta->table('contact_departments'); + +__PACKAGE__->meta->columns( + description => { type => 'text', not_null => 1 }, + id => { type => 'serial', not_null => 1 }, +); + +__PACKAGE__->meta->primary_key_columns([ 'id' ]); + +__PACKAGE__->meta->unique_keys([ 'description' ]); + +1; +; diff --git a/sql/Pg-upgrade2/contact_departments_own_table.sql b/sql/Pg-upgrade2/contact_departments_own_table.sql new file mode 100644 index 000000000..8535f1e92 --- /dev/null +++ b/sql/Pg-upgrade2/contact_departments_own_table.sql @@ -0,0 +1,15 @@ +-- @tag: contact_departments_own_table +-- @description: Eigene Tabelle für Abteilungen bei Ansprechpersonen +-- @depends: release_3_5_5 + +CREATE TABLE contact_departments ( + id SERIAL, + description TEXT NOT NULL, + PRIMARY KEY (id), + UNIQUE (description) +); + +UPDATE contacts SET cp_abteilung = trim(cp_abteilung) WHERE cp_abteilung NOT LIKE trim(cp_abteilung); + +INSERT INTO contact_departments (description) + SELECT DISTINCT cp_abteilung FROM contacts WHERE cp_abteilung IS NOT NULL AND cp_abteilung NOT LIKE '' ORDER BY cp_abteilung;