From: Moritz Bunkus Date: Wed, 27 Oct 2010 10:23:58 +0000 (+0200) Subject: DB-Upgrade-Script so modifiziert, dass es auch mehrfach auf ein und dieselbe Auth... X-Git-Tag: release-2.6.2beta1~89^2~6^2~1 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=59fd42b853b2655f5bd4078c72b47e13789bda26;p=kivitendo-erp.git DB-Upgrade-Script so modifiziert, dass es auch mehrfach auf ein und dieselbe Auth-DB ausgeführt werden kann --- diff --git a/sql/Pg-upgrade2/auth_enable_sales_all_edit.pl b/sql/Pg-upgrade2/auth_enable_sales_all_edit.pl index e223cd859..e77fbee65 100644 --- a/sql/Pg-upgrade2/auth_enable_sales_all_edit.pl +++ b/sql/Pg-upgrade2/auth_enable_sales_all_edit.pl @@ -13,38 +13,35 @@ sub mydberror { "
$msg
" . $DBI::errstr); } -sub do_query { - my ($query, $may_fail) = @_; +sub do_update { + my $dbh = $main::auth->dbconnect(); + my $query = <do($query)) { - mydberror($query) unless ($may_fail); - $dbh->rollback(); - $dbh->begin_work(); + $sth->finish(); + $dbh->commit(); } -} -sub do_update { - my @queries; - -# do_query("ALTER TABLE project ADD PRIMARY KEY (id);", 1); -# map({ do_query($_, 0); } @queries); -# print "hieryy"; -# print (Dumper($main::form)); - my $dbh = $main::auth->dbconnect(); - my $query = qq|SELECT distinct group_id from auth.user_group|; - my $sth_all_groups = prepare_execute_query($form, $dbh, $query); - while (my $hash_ref = $sth_all_groups->fetchrow_hashref()) { # Schleife - push @queries, "INSERT INTO auth.group_rights (group_id, \"right\", granted) VALUES (" . $hash_ref->{group_id} . ", 'sales_all_edit', 't')"; -} -# if in doubt use brute force ;-) jb - foreach my $query (@queries){ -# print "hier:" . $query; - my $dbh = $main::auth->dbconnect(); - my $sth = prepare_query($form, $dbh, $query); - do_statement($form,$sth,$query); - $sth->finish(); - $dbh ->commit(); -} return 1; }