From a53641328c7f20ae5de9de246fb6f3a1d3edf80c Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Sat, 26 Oct 2019 07:48:49 +0100 Subject: [PATCH] Bug 23805: (follow-up) Database update corrections Signed-off-by: Martin Renvoize --- installer/data/mysql/updatedatabase.pl | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index c606cae496..a0c00b43fb 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20015,9 +20015,8 @@ if ( CheckVersion($DBversion) ) { qq{ ALTER TABLE accountlines - ADD CONSTRAINT + DROP CHECK `accountlines_check_type` - CHECK (credit_type_code IS NOT NULL OR debit_type_code IS NOT NULL) } ); @@ -20073,19 +20072,35 @@ if ( CheckVersion($DBversion) ) { # Populating credit_type_code $dbh->do( qq{ - UPDATE accountlines SET credit_type_code = accounttype, accounttype = NULL WHERE accounttype IN (SELECT code from account_credit_types) + UPDATE + accountlines + SET + credit_type_code = accounttype, accounttype = NULL + WHERE accounttype IN (SELECT code from account_credit_types) } ); # Adding a check constraints to accountlines $dbh->do( qq{ - ALTER TABLE accountlines ADD CONSTRAINT `accountlines_check_type` CHECK (accounttype IS NOT NULL OR credit_type_code IS NOT NULL) + ALTER TABLE + accountlines + ADD CONSTRAINT + `accountlines_check_type` + CHECK (credit_type_code IS NOT NULL OR debit_type_code IS NOT NULL) + } + ); + + # Drop accounttype field + $dbh->do( + qq{ + ALTER TABLE accountlines + DROP COLUMN `accounttype` } ); SetVersion($DBversion); - print "Upgrade to $DBversion done (Bug 23049 - Add account credit_types)\n"; + print "Upgrade to $DBversion done (Bug 23805 - Add account credit_types)\n"; } # SEE bug 13068 -- 2.39.5