Anreden in eigene Tabelle: DB-Upgrade und Rose
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Fri, 17 Apr 2020 14:26:23 +0000 (16:26 +0200)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 11 May 2020 10:54:57 +0000 (12:54 +0200)
SL/DB/Greeting.pm [new file with mode: 0644]
SL/DB/Helper/ALL.pm
SL/DB/Helper/Mappings.pm
SL/DB/Manager/Greeting.pm [new file with mode: 0644]
SL/DB/MetaSetup/Greeting.pm [new file with mode: 0644]
sql/Pg-upgrade2/greetings_own_table.sql [new file with mode: 0644]

diff --git a/SL/DB/Greeting.pm b/SL/DB/Greeting.pm
new file mode 100644 (file)
index 0000000..fa0fa82
--- /dev/null
@@ -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;
index e6a6982..91f6378 100644 (file)
@@ -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;
index 4d1c5af..30e41f3 100644 (file)
@@ -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 (file)
index 0000000..dfe80db
--- /dev/null
@@ -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 (file)
index 0000000..5a38749
--- /dev/null
@@ -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 (file)
index 0000000..3921d57
--- /dev/null
@@ -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;