X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=sql%2FPg-upgrade%2FPg-upgrade-2.2.0.25-2.2.0.26.pl;h=eec34d0c50a2fffd91d5df42ac9dc8a96e70a673;hb=060494201059a4fe80c3c220079f834e625ff83b;hp=72a70ae4833c08bc2ffc0fc3b18f97f694dae5bc;hpb=f530dd672ae187327f28f5d08a10af3d126e4e1d;p=kivitendo-erp.git diff --git a/sql/Pg-upgrade/Pg-upgrade-2.2.0.25-2.2.0.26.pl b/sql/Pg-upgrade/Pg-upgrade-2.2.0.25-2.2.0.26.pl index 72a70ae48..eec34d0c5 100644 --- a/sql/Pg-upgrade/Pg-upgrade-2.2.0.25-2.2.0.26.pl +++ b/sql/Pg-upgrade/Pg-upgrade-2.2.0.25-2.2.0.26.pl @@ -1,5 +1,7 @@ #!/usr/bin/perl +# Datenbankupgrade: Einfuehrung von Einheiten + die("This script cannot be run from the command line.") unless ($main::form); use SL::AM; @@ -116,12 +118,12 @@ sub update_units_steps_1_2 { my ($query, $sth, $ref); if ($table eq "parts") { - $query = "SELECT unit, inventory_accno_id FROM parts " . + $query = "SELECT unit, inventory_accno_id, assembly FROM parts " . "WHERE NOT ((unit = '') OR unit ISNULL OR " . " unit IN (SELECT name FROM units))"; } else { - $query = "SELECT t.unit, p.inventory_accno_id " . + $query = "SELECT t.unit, p.inventory_accno_id, p.assembly " . "FROM $table t " . "LEFT JOIN parts p ON p.id = t.parts_id " . "WHERE NOT ((t.unit = '') OR t.unit ISNULL OR " . @@ -131,7 +133,7 @@ sub update_units_steps_1_2 { $sth->execute() || mydberror($query); while ($ref = $sth->fetchrow_hashref()) { - if ($ref->{"inventory_accno_id"}) { + if ($ref->{"inventory_accno_id"} || $ref->{"assembly"}) { $unknown_dimension_units{$ref->{"unit"}} = 1; } else { @@ -225,12 +227,14 @@ sub update_units_set_default { if ($table eq "parts") { $query = "UPDATE $table SET unit = " . $dbh->quote($form->{"default_dimension_unit"}) . " " . - "WHERE ((unit ISNULL) OR (unit = '')) AND (inventory_accno_id > 0)"; + "WHERE ((unit ISNULL) OR (unit = '')) AND " . + "(assembly OR (inventory_accno_id > 0))"; } else { $query = "UPDATE $table SET unit = " . $dbh->quote($form->{"default_dimension_unit"}) . " " . "WHERE ((unit ISNULL) OR (unit = '')) AND " . - "parts_id IN (SELECT id FROM parts WHERE (inventory_accno_id > 0))"; + "parts_id IN (SELECT id FROM parts WHERE " . + "(assembly OR (inventory_accno_id > 0)))"; } $dbh->do($query) || mydberror($query); @@ -239,13 +243,15 @@ sub update_units_set_default { $query = "UPDATE $table SET unit = " . $dbh->quote($form->{"default_service_unit"}) . " " . "WHERE ((unit ISNULL) OR (unit = '')) AND " . - "(inventory_accno_id ISNULL) OR (inventory_accno_id = 0)"; + "((inventory_accno_id ISNULL) OR (inventory_accno_id = 0)) AND " . + "NOT assembly"; } else { $query = "UPDATE $table SET unit = " . $dbh->quote($form->{"default_service_unit"}) . " " . "WHERE ((unit ISNULL) OR (unit = '')) AND " . "parts_id IN (SELECT id FROM parts " . - "WHERE (inventory_accno_id ISNULL) OR (inventory_accno_id = 0))"; + "WHERE ((inventory_accno_id ISNULL) OR (inventory_accno_id = 0)) " . + "AND NOT assembly)"; } $dbh->do($query) || mydberror($query);