DeliveryOrder order_type db upgrade
authorSven Schöling <s.schoeling@googlemail.com>
Fri, 1 Oct 2021 14:34:34 +0000 (16:34 +0200)
committerJan Büren <jan@kivitendo.de>
Mon, 14 Feb 2022 13:53:49 +0000 (14:53 +0100)
is_sales noch nicht in der datenbank entfernt, nur im metasetup

SL/DB/MetaSetup/DeliveryOrder.pm
sql/Pg-upgrade2/deliveryorder_type.sql [new file with mode: 0644]

index f24fc9f..994fa96 100644 (file)
@@ -23,11 +23,11 @@ __PACKAGE__->meta->columns(
   globalproject_id        => { type => 'integer' },
   id                      => { type => 'integer', not_null => 1, sequence => 'id' },
   intnotes                => { type => 'text' },
-  is_sales                => { type => 'boolean' },
   itime                   => { type => 'timestamp', default => 'now()' },
   language_id             => { type => 'integer' },
   mtime                   => { type => 'timestamp' },
   notes                   => { type => 'text' },
+  order_type              => { type => 'text', not_null => 1 },
   ordnumber               => { type => 'text' },
   oreqnumber              => { type => 'text' },
   payment_id              => { type => 'integer' },
diff --git a/sql/Pg-upgrade2/deliveryorder_type.sql b/sql/Pg-upgrade2/deliveryorder_type.sql
new file mode 100644 (file)
index 0000000..8e4a0f4
--- /dev/null
@@ -0,0 +1,12 @@
+-- @tag: deliveryorder_type
+-- @description: Persistente Typen in Lieferscheinen
+-- @depends: release_3_5_8
+
+ALTER TABLE delivery_orders ADD COLUMN order_type TEXT;
+
+UPDATE delivery_orders SET order_type = 'sales_delivery_order' WHERE customer_id IS NOT NULL;
+UPDATE delivery_orders SET order_type = 'purchase_delivery_order' WHERE vendor_id IS NOT NULL;
+
+ALTER TABLE delivery_orders ALTER COLUMN order_type SET NOT NULL;
+
+