From 93f857584b9a2545cdc4145c00c6ed1a790b32d4 Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Thu, 16 Mar 2023 15:33:39 -0300
Subject: [PATCH] Bug 8179: Modernize atomic update

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
---
 installer/data/mysql/atomicupdate/bug_8179.perl | 15 ---------------
 installer/data/mysql/atomicupdate/bug_8179.pl   | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 15 deletions(-)
 delete mode 100644 installer/data/mysql/atomicupdate/bug_8179.perl
 create mode 100755 installer/data/mysql/atomicupdate/bug_8179.pl

diff --git a/installer/data/mysql/atomicupdate/bug_8179.perl b/installer/data/mysql/atomicupdate/bug_8179.perl
deleted file mode 100644
index efd5000e10d..00000000000
--- a/installer/data/mysql/atomicupdate/bug_8179.perl
+++ /dev/null
@@ -1,15 +0,0 @@
-$DBversion = 'XXX'; # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-    # you can use $dbh here like:
-    $dbh->do( qq{
-        INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
-        ('AcqReceiveMultipleOrderLines', '0', NULL, 'Process multiple order lines at once', 'YesNo')
-    });
-    # or perform some test and warn
-    # if( !column_exists( 'biblio', 'biblionumber' ) ) {
-    #    warn "There is something wrong";
-    # }
-
-    # Always end with this (adjust the bug info)
-    NewVersion( $DBversion, 8179, "Add AcqReceiveMultipleOrderLines system preference");
-}
diff --git a/installer/data/mysql/atomicupdate/bug_8179.pl b/installer/data/mysql/atomicupdate/bug_8179.pl
new file mode 100755
index 00000000000..190f03c6748
--- /dev/null
+++ b/installer/data/mysql/atomicupdate/bug_8179.pl
@@ -0,0 +1,17 @@
+use Modern::Perl;
+
+return {
+    bug_number  => "8179",
+    description => "Acquisitions orders: multi-receive",
+    up => sub {
+        my ($args) = @_;
+        my ($dbh, $out) = @$args{qw(dbh out)};
+
+        $dbh->do(q{
+            INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
+            ('AcqReceiveMultipleOrderLines', '0', NULL, 'Process multiple order lines at once', 'YesNo')
+        });
+
+        say $out "Added new system preference 'AcqReceiveMultipleOrderLines'";
+    },
+};
-- 
2.40.0