X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=sql%2FPg-upgrade2%2Fwarehouse.pl;h=6eebb2f7bdba6a52251909a7cb30f99564ec444b;hb=0d12df6dc721dcdbc81ca8db667cd644393bc5fc;hp=5fad058396f61af682ff687b036cdcd313d03ff2;hpb=5f0a5514943bce086319e6f02b31808874e680eb;p=kivitendo-erp.git diff --git a/sql/Pg-upgrade2/warehouse.pl b/sql/Pg-upgrade2/warehouse.pl index 5fad05839..6eebb2f7b 100644 --- a/sql/Pg-upgrade2/warehouse.pl +++ b/sql/Pg-upgrade2/warehouse.pl @@ -1,71 +1,26 @@ # @tag: warehouse # @description: Diverse neue Tabellen und Spalten zur Mehrlagerfähigkeit inkl. Migration # @depends: release_2_4_3 +package SL::DBUpgrade2::warehouse; +use strict; +use utf8; -die("This script cannot be run from the command line.") unless ($main::form); -$do_sql_migration = 0; +use parent qw(SL::DBUpgrade2::Base); -sub print_question { - print $main::form->parse_html_template("dbupgrade/warehouse_form"); -} - -sub do_update { - if (!$main::form->{do_migrate} - && (selectfirst_array_query($main::form, $dbh, $check_sql))[0]) { # check if update is needed - print_question(); - return 2; - } else { - if ($main::form->{do_migrate} eq 'Y') { - # if yes, both warehouse and bin must be given - if (!$main::form->{import_warehouse} || !$main::form->{bin_default}) { - print_question(); - return 2; - } - # flag for extra code - $do_sql_migration = 1; - } - } - my $warehouse = $main::form->{import_warehouse} ne '' ? $main::form->{import_warehouse} : "Transfer"; - my $bin = $main::form->{bin_default} ne '' ? $main::form->{bin_default} : "1"; +use SL::DBUtils; - - my $migration_code = <parse_html_template("dbupgrade/warehouse_form"); } +sub run { + my ($self) = @_; - -$sqlcode = < 0;|; + my $sqlcode = < 0; ALTER TABLE parts DROP COLUMN onhand; ALTER TABLE parts ADD COLUMN onhand numeric(25,5); @@ -179,13 +133,59 @@ END; CREATE TRIGGER trig_update_onhand AFTER INSERT OR UPDATE OR DELETE ON inventory FOR EACH ROW EXECUTE PROCEDURE update_onhand(); -EOF -; +SQL + + if (!$::form->{do_migrate} + && (selectfirst_array_query($::form, $self->dbh, $check_sql))[0]) { # check if update is needed + print_question(); + return 2; + } else { + if (defined $::form->{do_migrate} && $::form->{do_migrate} eq 'Y') { + # if yes, both warehouse and bin must be given + if (!$::form->{import_warehouse} || !$::form->{bin_default}) { + print_question(); + return 2; + } + # flag for extra code + $do_sql_migration = 1; + } + } + my $warehouse = defined $::form->{import_warehouse} && $::form->{import_warehouse} ne '' ? $::form->{import_warehouse} : "Transfer"; + my $bin = defined $::form->{bin_default} && $::form->{bin_default} ne '' ? $::form->{bin_default} : "1"; + $warehouse = $self->dbh->quote($warehouse); + $bin = $self->dbh->quote($bin); -$check_sql = < 0; + my $migration_code = <db_query($query); + + return 1; +} + +1;