From 59fd42b853b2655f5bd4078c72b47e13789bda26 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 27 Oct 2010 12:23:58 +0200 Subject: [PATCH] =?utf8?q?DB-Upgrade-Script=20so=20modifiziert,=20dass=20e?= =?utf8?q?s=20auch=20mehrfach=20auf=20ein=20und=20dieselbe=20Auth-DB=20aus?= =?utf8?q?gef=C3=BChrt=20werden=20kann?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- sql/Pg-upgrade2/auth_enable_sales_all_edit.pl | 55 +++++++++---------- 1 file changed, 26 insertions(+), 29 deletions(-) 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; } -- 2.20.1