Bug 18639: Alter DB update to populate replacementprice from rpp initially
authorNick Clemens <nick@bywatersolutions.com>
Mon, 27 Aug 2018 18:21:23 +0000 (18:21 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 31 Aug 2018 12:46:51 +0000 (12:46 +0000)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
installer/data/mysql/atomicupdate/bug_18639_add_replacementprice_field_to_aqorders.perl

index 004d6ab..152b14d 100644 (file)
@@ -1,6 +1,9 @@
 $DBversion = 'XXX';  # will be replaced by the RM
 if( CheckVersion( $DBversion ) ) {
-    $dbh->do( "ALTER TABLE  aqorders ADD COLUMN replacementprice DECIMAL(28,6)" );
+    if( !column_exists( 'aqorders', 'replacementprice' ){
+        $dbh->do( "ALTER TABLE  aqorders ADD COLUMN replacementprice DECIMAL(28,6)" );
+        $dbh->do( "UPDATE aqorders set replacementprice = rrp WHERE replacementprice IS NULL" );
+    }
     SetVersion( $DBversion );
     print "Upgrade to $DBversion done (Bug 18639 - Add replacementprice field to aqorders table)\n";
 }