Bug 23081: atomicupdate for change to existing installs
authorAndrew Fuerste-Henry <andrew@bywatersolutions.com>
Sun, 26 Apr 2020 23:53:26 +0000 (23:53 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 27 Apr 2020 10:32:47 +0000 (11:32 +0100)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
installer/data/mysql/atomicupdate/bug_23081-change-default-of-issues-field.perl [new file with mode: 0644]

diff --git a/installer/data/mysql/atomicupdate/bug_23081-change-default-of-issues-field.perl b/installer/data/mysql/atomicupdate/bug_23081-change-default-of-issues-field.perl
new file mode 100644 (file)
index 0000000..204d999
--- /dev/null
@@ -0,0 +1,15 @@
+$DBversion = 'XXX'; # will be replaced by the RM
+if( CheckVersion( $DBversion ) ) {
+    # you can use $dbh here like:
+     $dbh->do( "UPDATE items set issues=0 where issues is null" );
+     $dbh->do( "UPDATE deleteditems set issues=0 where issues is null" );
+     $dbh->do( "ALTER TABLE items ALTER issues set default 0" );
+     $dbh->do( "ALTER TABLE deleteditems ALTER issues set default 0" );
+    # 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, 23081, "Set default to 0 for items.issues");
+}