@@ -, +, @@ --- installer/data/mysql/atomicupdate/bug_23049_debit.perl | 6 ++++++ installer/data/mysql/kohastructure.sql | 1 + 2 files changed, 7 insertions(+) --- a/installer/data/mysql/atomicupdate/bug_23049_debit.perl +++ a/installer/data/mysql/atomicupdate/bug_23049_debit.perl @@ -89,6 +89,12 @@ if ( CheckVersion($DBversion) ) { } ); + $dbh->do( + qq{ + ALTER TABLE accountlines ADD CONSTRAINT `accountlines_check_type` CHECK (accounttype IS NOT NULL OR debit_type IS NOT NULL) + } + ); + $dbh->do( qq{ UPDATE accountlines SET debit_type = accounttype, accounttype = NULL WHERE accounttype IN (SELECT code from account_debit_types) --- a/installer/data/mysql/kohastructure.sql +++ a/installer/data/mysql/kohastructure.sql @@ -2678,6 +2678,7 @@ CREATE TABLE `accountlines` ( KEY `itemnumber` (`itemnumber`), KEY `branchcode` (`branchcode`), KEY `manager_id` (`manager_id`), + CONSTRAINT `accountlines_check_type` CHECK (accounttype IS NOT NULL OR debit_type IS NOT NULL), CONSTRAINT `accountlines_ibfk_borrowers` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `accountlines_ibfk_items` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE SET NULL ON UPDATE CASCADE, CONSTRAINT `accountlines_ibfk_borrowers_2` FOREIGN KEY (`manager_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, --