From c43e167255e63a2ff02f09af5d20ed67b6ffc816 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 29 Oct 2019 13:34:09 +0000 Subject: [PATCH] Bug 23805: (follow-up) [alternative] Re-order check constraint --- installer/data/mysql/updatedatabase.pl | 28 +++++++++----------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a0c00b43fb..7d069353c3 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20010,16 +20010,6 @@ if ( CheckVersion($DBversion) ) { ); } - # Dropping the check constraint in accountlines - $dbh->do( - qq{ - ALTER TABLE - accountlines - DROP CHECK - `accountlines_check_type` - } - ); - # Update accountype 'C' to 'CREDIT' $dbh->do( qq{ @@ -20075,11 +20065,19 @@ if ( CheckVersion($DBversion) ) { UPDATE accountlines SET - credit_type_code = accounttype, accounttype = NULL + credit_type_code = accounttype WHERE accounttype IN (SELECT code from account_credit_types) } ); + # Drop accounttype field + $dbh->do( + qq{ + ALTER TABLE accountlines + DROP COLUMN `accounttype` + } + ); + # Adding a check constraints to accountlines $dbh->do( qq{ @@ -20091,14 +20089,6 @@ if ( CheckVersion($DBversion) ) { } ); - # Drop accounttype field - $dbh->do( - qq{ - ALTER TABLE accountlines - DROP COLUMN `accounttype` - } - ); - SetVersion($DBversion); print "Upgrade to $DBversion done (Bug 23805 - Add account credit_types)\n"; } -- 2.20.1