From 041274eeffcf6a17037cfb759d11aa4d33b2e567 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bernd=20Ble=C3=9Fmann?= Date: Fri, 17 Apr 2020 16:26:23 +0200 Subject: [PATCH] Anreden in eigene Tabelle: DB-Upgrade und Rose --- SL/DB/Greeting.pm | 13 +++++++++++++ SL/DB/Helper/ALL.pm | 1 + SL/DB/Helper/Mappings.pm | 1 + SL/DB/Manager/Greeting.pm | 14 ++++++++++++++ SL/DB/MetaSetup/Greeting.pm | 21 +++++++++++++++++++++ sql/Pg-upgrade2/greetings_own_table.sql | 16 ++++++++++++++++ 6 files changed, 66 insertions(+) create mode 100644 SL/DB/Greeting.pm create mode 100644 SL/DB/Manager/Greeting.pm create mode 100644 SL/DB/MetaSetup/Greeting.pm create mode 100644 sql/Pg-upgrade2/greetings_own_table.sql diff --git a/SL/DB/Greeting.pm b/SL/DB/Greeting.pm new file mode 100644 index 000000000..fa0fa82bf --- /dev/null +++ b/SL/DB/Greeting.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::Greeting; + +use strict; + +use SL::DB::MetaSetup::Greeting; +use SL::DB::Manager::Greeting; + +__PACKAGE__->meta->initialize; + +1; diff --git a/SL/DB/Helper/ALL.pm b/SL/DB/Helper/ALL.pm index e6a698282..91f637860 100644 --- a/SL/DB/Helper/ALL.pm +++ b/SL/DB/Helper/ALL.pm @@ -62,6 +62,7 @@ use SL::DB::FollowUpAccess; use SL::DB::FollowUpLink; use SL::DB::GLTransaction; use SL::DB::GenericTranslation; +use SL::DB::Greeting; use SL::DB::History; use SL::DB::Inventory; use SL::DB::Invoice; diff --git a/SL/DB/Helper/Mappings.pm b/SL/DB/Helper/Mappings.pm index 4d1c5af31..30e41f309 100644 --- a/SL/DB/Helper/Mappings.pm +++ b/SL/DB/Helper/Mappings.pm @@ -146,6 +146,7 @@ my %kivitendo_package_names = ( follow_ups => 'follow_up', generic_translations => 'generic_translation', gl => 'GLTransaction', + greetings => 'greeting', history_erp => 'history', inventory => 'inventory', invoice => 'invoice_item', diff --git a/SL/DB/Manager/Greeting.pm b/SL/DB/Manager/Greeting.pm new file mode 100644 index 000000000..dfe80db1d --- /dev/null +++ b/SL/DB/Manager/Greeting.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::Greeting; + +use strict; + +use parent qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::Greeting' } + +__PACKAGE__->make_manager_methods; + +1; diff --git a/SL/DB/MetaSetup/Greeting.pm b/SL/DB/MetaSetup/Greeting.pm new file mode 100644 index 000000000..5a3874981 --- /dev/null +++ b/SL/DB/MetaSetup/Greeting.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::Greeting; + +use strict; + +use parent qw(SL::DB::Object); + +__PACKAGE__->meta->table('greetings'); + +__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/greetings_own_table.sql b/sql/Pg-upgrade2/greetings_own_table.sql new file mode 100644 index 000000000..3921d571b --- /dev/null +++ b/sql/Pg-upgrade2/greetings_own_table.sql @@ -0,0 +1,16 @@ +-- @tag: greetings_own_table +-- @description: Eigene Tabelle für Anreden +-- @depends: release_3_5_5 + +CREATE TABLE greetings ( + id SERIAL, + description TEXT NOT NULL, + PRIMARY KEY (id), + UNIQUE (description) +); + +UPDATE customer SET greeting = trim(greeting) WHERE greeting NOT LIKE trim(greeting); +UPDATE vendor SET greeting = trim(greeting) WHERE greeting NOT LIKE trim(greeting); + +INSERT INTO greetings (description) + SELECT DISTINCT greeting FROM (SELECT greeting FROM customer UNION SELECT greeting FROM vendor) AS gr WHERE greeting IS NOT NULL AND greeting NOT LIKE '' ORDER BY greeting; -- 2.20.1