From 6cde4d1d7e444d3471f7329153c2d18f8daac85f Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 7 Feb 2014 10:35:20 +0100 Subject: [PATCH] =?utf8?q?Fremschl=C3=BCssel=20f=C3=BCr=20=C2=BBunit=C2=AB?= =?utf8?q?=20in=20Tabellen=20orderitems,=20delivery=5Forder=5Fitems,=20inv?= =?utf8?q?oice?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/DB/DeliveryOrderItem.pm | 7 ------- SL/DB/InvoiceItem.pm | 8 -------- SL/DB/MetaSetup/DeliveryOrderItem.pm | 5 +++++ SL/DB/MetaSetup/InvoiceItem.pm | 5 +++++ SL/DB/MetaSetup/OrderItem.pm | 5 +++++ SL/DB/OrderItem.pm | 8 -------- sql/Pg-upgrade2/unit_foreign_key_for_line_items.sql | 6 ++++++ 7 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 sql/Pg-upgrade2/unit_foreign_key_for_line_items.sql diff --git a/SL/DB/DeliveryOrderItem.pm b/SL/DB/DeliveryOrderItem.pm index 29c85a2cb..638082ccf 100644 --- a/SL/DB/DeliveryOrderItem.pm +++ b/SL/DB/DeliveryOrderItem.pm @@ -15,13 +15,6 @@ use SL::DB::Helper::CustomVariables ( ); __PACKAGE__->meta->make_manager_class; -__PACKAGE__->meta->add_relationship( - unit_obj => { - type => 'many to one', - class => 'SL::DB::Unit', - column_map => { unit => 'name' }, - }, -); __PACKAGE__->meta->initialize; diff --git a/SL/DB/InvoiceItem.pm b/SL/DB/InvoiceItem.pm index 8f9a4dde7..eeeb679fc 100644 --- a/SL/DB/InvoiceItem.pm +++ b/SL/DB/InvoiceItem.pm @@ -14,14 +14,6 @@ use SL::DB::Helper::CustomVariables ( }, ); -__PACKAGE__->meta->add_relationship( - unit_obj => { - type => 'many to one', - class => 'SL::DB::Unit', - column_map => { unit => 'name' }, - }, -); - # Creates get_all, get_all_count, get_all_iterator, delete_all and update_all. __PACKAGE__->meta->make_manager_class; diff --git a/SL/DB/MetaSetup/DeliveryOrderItem.pm b/SL/DB/MetaSetup/DeliveryOrderItem.pm index 7735c9ea8..54f261f28 100644 --- a/SL/DB/MetaSetup/DeliveryOrderItem.pm +++ b/SL/DB/MetaSetup/DeliveryOrderItem.pm @@ -63,6 +63,11 @@ __PACKAGE__->meta->foreign_keys( class => 'SL::DB::Project', key_columns => { project_id => 'id' }, }, + + unit_obj => { + class => 'SL::DB::Unit', + key_columns => { unit => 'name' }, + }, ); 1; diff --git a/SL/DB/MetaSetup/InvoiceItem.pm b/SL/DB/MetaSetup/InvoiceItem.pm index d527f76f5..86e0a9d5d 100644 --- a/SL/DB/MetaSetup/InvoiceItem.pm +++ b/SL/DB/MetaSetup/InvoiceItem.pm @@ -64,6 +64,11 @@ __PACKAGE__->meta->foreign_keys( class => 'SL::DB::Project', key_columns => { project_id => 'id' }, }, + + unit_obj => { + class => 'SL::DB::Unit', + key_columns => { unit => 'name' }, + }, ); 1; diff --git a/SL/DB/MetaSetup/OrderItem.pm b/SL/DB/MetaSetup/OrderItem.pm index 66d2ad261..e3a66d531 100644 --- a/SL/DB/MetaSetup/OrderItem.pm +++ b/SL/DB/MetaSetup/OrderItem.pm @@ -67,6 +67,11 @@ __PACKAGE__->meta->foreign_keys( class => 'SL::DB::Project', key_columns => { project_id => 'id' }, }, + + unit_obj => { + class => 'SL::DB::Unit', + key_columns => { unit => 'name' }, + }, ); 1; diff --git a/SL/DB/OrderItem.pm b/SL/DB/OrderItem.pm index 37520977b..e75c78f5f 100644 --- a/SL/DB/OrderItem.pm +++ b/SL/DB/OrderItem.pm @@ -17,14 +17,6 @@ use SL::DB::Helper::CustomVariables ( }, ); -__PACKAGE__->meta->add_relationship( - unit_obj => { - type => 'many to one', - class => 'SL::DB::Unit', - column_map => { unit => 'name' }, - }, -); - __PACKAGE__->meta->initialize; sub is_price_update_available { diff --git a/sql/Pg-upgrade2/unit_foreign_key_for_line_items.sql b/sql/Pg-upgrade2/unit_foreign_key_for_line_items.sql new file mode 100644 index 000000000..d99e1a7fa --- /dev/null +++ b/sql/Pg-upgrade2/unit_foreign_key_for_line_items.sql @@ -0,0 +1,6 @@ +-- @tag: unit_foreign_key_for_line_items +-- @description: Fremdschlüssel auf »unit« für Beleg-Positionstabellen +-- @depends: release_3_0_0 +ALTER TABLE orderitems ADD FOREIGN KEY (unit) REFERENCES units (name); +ALTER TABLE delivery_order_items ADD FOREIGN KEY (unit) REFERENCES units (name); +ALTER TABLE invoice ADD FOREIGN KEY (unit) REFERENCES units (name); -- 2.20.1