From c88ff4945443d829149f0033f128fb1627b89744 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 15 Feb 2023 09:01:54 +0100 Subject: [PATCH] Bug 25655: Update existing orders in DB --- installer/data/mysql/atomicupdate/bug_25655.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_25655.pl b/installer/data/mysql/atomicupdate/bug_25655.pl index 01be1a1ee21..e8f0d2f729f 100755 --- a/installer/data/mysql/atomicupdate/bug_25655.pl +++ b/installer/data/mysql/atomicupdate/bug_25655.pl @@ -11,6 +11,10 @@ return { ALTER TABLE aqorders ADD COLUMN invoice_unitprice decimal(28,6) DEFAULT NULL COMMENT 'the unit price in foreign currency' AFTER estimated_delivery_date }); + $dbh->do(q{ + UPDATE aqorders + SET invoice_unitprice=unitprice + }); } say $out "Added column 'aqorders.invoice_unitprice'"; @@ -20,6 +24,15 @@ return { ADD COLUMN invoice_currency varchar(10) DEFAULT NULL COMMENT 'the currency of the invoice_unitprice' AFTER invoice_unitprice, ADD CONSTRAINT `aqorders_invoice_currency` FOREIGN KEY (`invoice_currency`) REFERENCES `currency` (`currency`) ON DELETE SET NULL ON UPDATE SET NULL }); + my ( $active_currency ) = $dbh->selectrow_array(q{ + SELECT currency + FROM currency + WHERE active = 1 + }); + $dbh->do(q{ + UPDATE aqorders + SET invoice_currency = ? + }, undef, $active_currency); } say $out "Added column 'aqorders.invoice_currency'"; }, -- 2.25.1