X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=sql%2FPg-upgrade2%2Fwarehouse.pl;h=a9b152f9e8bf2c4c652d817ea2ad0c491591da8c;hb=05e6d940371b65fe76a6a25354e156ae8e13a76c;hp=f9e59a4e5e19e0259bc2ab4dd2319adfcbecf4f4;hpb=4b4c9020f4ae9b4a79d11b8bc17e75405fcfef72;p=kivitendo-erp.git diff --git a/sql/Pg-upgrade2/warehouse.pl b/sql/Pg-upgrade2/warehouse.pl index f9e59a4e5..a9b152f9e 100644 --- a/sql/Pg-upgrade2/warehouse.pl +++ b/sql/Pg-upgrade2/warehouse.pl @@ -2,9 +2,13 @@ # @description: Diverse neue Tabellen und Spalten zur Mehrlagerfähigkeit inkl. Migration # @depends: release_2_4_3 +use strict; die("This script cannot be run from the command line.") unless ($main::form); +my $do_sql_migration = 0; +my ($check_sql, $sqlcode); + sub mydberror { my ($msg) = @_; die($dbup_locale->text("Database update error:") . @@ -21,7 +25,6 @@ sub do_query { } } -$do_sql_migration = 0; sub print_question { print $main::form->parse_html_template("dbupgrade/warehouse_form"); @@ -57,17 +60,17 @@ INSERT INTO warehouse (description, sortkey, invalid) VALUES ($warehouse, 1, FAL UPDATE tmp_parts SET bin = NULL WHERE bin = ''; -- Restore old onhand -INSERT INTO bin - (warehouse_id, description) - (SELECT DISTINCT warehouse.id, COALESCE(bin, $bin) - FROM warehouse, tmp_parts +INSERT INTO bin + (warehouse_id, description) + (SELECT DISTINCT warehouse.id, COALESCE(bin, $bin) + FROM warehouse, tmp_parts WHERE warehouse.description=$warehouse); -INSERT INTO inventory +INSERT INTO inventory (warehouse_id, parts_id, bin_id, qty, employee_id, trans_id, trans_type_id, chargenumber) (SELECT warehouse.id, tmp_parts.id, bin.id, onhand, (SELECT id FROM employee LIMIT 1), nextval('id'), transfer_type.id, '' FROM transfer_type, warehouse, tmp_parts, bin WHERE warehouse.description = $warehouse - AND COALESCE(bin, $bin) = bin.description + AND COALESCE(bin, $bin) = bin.description AND transfer_type.description = 'stock'); EOF ;