From f762b8c62bd718b22d3d85653a059486b552422a Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 26 Sep 2019 14:36:06 +0100 Subject: [PATCH] Bug 23049: Add CHECK constraint to accountlines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine QUEUNE --- installer/data/mysql/atomicupdate/bug_23049_debit.perl | 6 ++++++ installer/data/mysql/kohastructure.sql | 1 + 2 files changed, 7 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_23049_debit.perl b/installer/data/mysql/atomicupdate/bug_23049_debit.perl index 60d5b0c..fbc9d56 100644 --- a/installer/data/mysql/atomicupdate/bug_23049_debit.perl +++ b/installer/data/mysql/atomicupdate/bug_23049_debit.perl @@ -85,6 +85,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) + } + ); + # Add new permission $dbh->do( q{ diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 1cb81cb..a70c5c2 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -2677,6 +2677,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, -- 2.7.4