Zeiterfassung: Auswählbare Artikel: DB-Upgrade und Rose
authorBernd Bleßmann <bernd@kivitendo-premium.de>
Mon, 28 Dec 2020 17:40:36 +0000 (18:40 +0100)
committerBernd Bleßmann <bernd@kivitendo-premium.de>
Wed, 5 May 2021 15:25:03 +0000 (17:25 +0200)
SL/DB/Helper/ALL.pm
SL/DB/Helper/Mappings.pm
SL/DB/Manager/TimeRecordingArticle.pm [new file with mode: 0644]
SL/DB/MetaSetup/TimeRecording.pm
SL/DB/MetaSetup/TimeRecordingArticle.pm [new file with mode: 0644]
SL/DB/TimeRecordingArticle.pm [new file with mode: 0644]
sql/Pg-upgrade2/time_recordings_articles.sql [new file with mode: 0644]

index 52f1321..e0ab578 100644 (file)
@@ -135,6 +135,7 @@ use SL::DB::TaxKey;
 use SL::DB::TaxZone;
 use SL::DB::TaxzoneChart;
 use SL::DB::TimeRecording;
+use SL::DB::TimeRecordingArticle;
 use SL::DB::TodoUserConfig;
 use SL::DB::TransferType;
 use SL::DB::Translation;
index 7b69b53..94f7e47 100644 (file)
@@ -214,6 +214,7 @@ my %kivitendo_package_names = (
   taxkeys                        => 'tax_key',
   tax_zones                      => 'tax_zone',
   taxzone_charts                 => 'taxzone_chart',
+  time_recording_articles        => 'time_recording_article',
   time_recordings                => 'time_recording',
   todo_user_config               => 'todo_user_config',
   transfer_type                  => 'transfer_type',
diff --git a/SL/DB/Manager/TimeRecordingArticle.pm b/SL/DB/Manager/TimeRecordingArticle.pm
new file mode 100644 (file)
index 0000000..9f4b9e8
--- /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::TimeRecordingArticle;
+
+use strict;
+
+use parent qw(SL::DB::Helper::Manager);
+
+sub object_class { 'SL::DB::TimeRecordingArticle' }
+
+__PACKAGE__->make_manager_methods;
+
+1;
index e35141b..4fca657 100644 (file)
@@ -17,6 +17,7 @@ __PACKAGE__->meta->columns(
   id              => { type => 'serial', not_null => 1 },
   itime           => { type => 'timestamp', default => 'now()', not_null => 1 },
   mtime           => { type => 'timestamp', default => 'now()', not_null => 1 },
+  part_id         => { type => 'integer' },
   payroll         => { type => 'boolean', default => 'false' },
   project_id      => { type => 'integer' },
   staff_member_id => { type => 'integer', not_null => 1 },
@@ -38,6 +39,11 @@ __PACKAGE__->meta->foreign_keys(
     key_columns => { employee_id => 'id' },
   },
 
+  part => {
+    class       => 'SL::DB::Part',
+    key_columns => { part_id => 'id' },
+  },
+
   project => {
     class       => 'SL::DB::Project',
     key_columns => { project_id => 'id' },
diff --git a/SL/DB/MetaSetup/TimeRecordingArticle.pm b/SL/DB/MetaSetup/TimeRecordingArticle.pm
new file mode 100644 (file)
index 0000000..5d7bd84
--- /dev/null
@@ -0,0 +1,30 @@
+# This file has been auto-generated. Do not modify it; it will be overwritten
+# by rose_auto_create_model.pl automatically.
+package SL::DB::TimeRecordingArticle;
+
+use strict;
+
+use parent qw(SL::DB::Object);
+
+__PACKAGE__->meta->table('time_recording_articles');
+
+__PACKAGE__->meta->columns(
+  id       => { type => 'serial', not_null => 1 },
+  part_id  => { type => 'integer', not_null => 1 },
+  position => { type => 'integer', not_null => 1 },
+);
+
+__PACKAGE__->meta->primary_key_columns([ 'id' ]);
+
+__PACKAGE__->meta->unique_keys([ 'part_id' ]);
+
+__PACKAGE__->meta->foreign_keys(
+  part => {
+    class       => 'SL::DB::Part',
+    key_columns => { part_id => 'id' },
+    rel_type    => 'one to one',
+  },
+);
+
+1;
+;
diff --git a/SL/DB/TimeRecordingArticle.pm b/SL/DB/TimeRecordingArticle.pm
new file mode 100644 (file)
index 0000000..9887ce3
--- /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::TimeRecordingArticle;
+
+use strict;
+
+use SL::DB::MetaSetup::TimeRecordingArticle;
+use SL::DB::Manager::TimeRecordingArticle;
+
+__PACKAGE__->meta->initialize;
+
+1;
diff --git a/sql/Pg-upgrade2/time_recordings_articles.sql b/sql/Pg-upgrade2/time_recordings_articles.sql
new file mode 100644 (file)
index 0000000..c693c36
--- /dev/null
@@ -0,0 +1,13 @@
+-- @tag: time_recordings_articles
+-- @description: Zeiterfassungs-Artikel
+-- @depends: time_recordings
+
+CREATE TABLE time_recording_articles (
+  id                 SERIAL,
+  part_id            INTEGER  REFERENCES parts(id) UNIQUE NOT NULL,
+  position           INTEGER  NOT NULL,
+
+  PRIMARY KEY (id)
+);
+
+ALTER TABLE time_recordings ADD COLUMN part_id INTEGER REFERENCES parts(id);