Bug 30624: Make DB update idempotent
authorLucas Gass <lucas@bywatersolutions.com>
Mon, 13 Mar 2023 12:17:32 +0000 (12:17 +0000)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 13 Mar 2023 18:23:24 +0000 (15:23 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
installer/data/mysql/atomicupdate/bug_30624_add_userflag.pl

index c4b1d5c..db13f6c 100755 (executable)
@@ -13,7 +13,7 @@ return {
         my $IndependentBranches = C4::Context->preference('IndependentBranches');
         unless ( $IndependentBranches ) {
             $dbh->do(q{
-                UPDATE borrowers SET flags = flags + (1<<29) WHERE flags & 4;
+                UPDATE borrowers SET flags = flags + (1<<29) WHERE ( flags & 4 AND !(flags & 1<<29) ) ;
            });
         }
     },