Fremschlüssel für »unit« in Tabellen orderitems, delivery_order_items, invoice
authorMoritz Bunkus <m.bunkus@linet-services.de>
Fri, 7 Feb 2014 09:35:20 +0000 (10:35 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Mon, 24 Feb 2014 13:40:01 +0000 (14:40 +0100)
SL/DB/DeliveryOrderItem.pm
SL/DB/InvoiceItem.pm
SL/DB/MetaSetup/DeliveryOrderItem.pm
SL/DB/MetaSetup/InvoiceItem.pm
SL/DB/MetaSetup/OrderItem.pm
SL/DB/OrderItem.pm
sql/Pg-upgrade2/unit_foreign_key_for_line_items.sql [new file with mode: 0644]

index 29c85a2..638082c 100644 (file)
@@ -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;
 
index 8f9a4dd..eeeb679 100644 (file)
@@ -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;
 
index 7735c9e..54f261f 100644 (file)
@@ -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;
index d527f76..86e0a9d 100644 (file)
@@ -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;
index 66d2ad2..e3a66d5 100644 (file)
@@ -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;
index 3752097..e75c78f 100644 (file)
@@ -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 (file)
index 0000000..d99e1a7
--- /dev/null
@@ -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);