From 3b489bc24e2b9c39110ed0ec7dc4f9ff28f12966 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Sat, 29 Sep 2018 17:29:44 -0300 Subject: [PATCH] Bug 18887: Add foreign keys Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens --- installer/data/mysql/atomicupdate/bug_18887.perl | 7 ++++--- installer/data/mysql/kohastructure.sql | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/installer/data/mysql/atomicupdate/bug_18887.perl b/installer/data/mysql/atomicupdate/bug_18887.perl index 85da1d207e..97eb1efa42 100644 --- a/installer/data/mysql/atomicupdate/bug_18887.perl +++ b/installer/data/mysql/atomicupdate/bug_18887.perl @@ -11,9 +11,10 @@ if( CheckVersion( $DBversion ) ) { `rule_name` varchar(32) NOT NULL, `rule_value` varchar(32) NOT NULL, PRIMARY KEY (`id`), - KEY `branchcode` (`branchcode`), - KEY `categorycode` (`categorycode`), - KEY `itemtype` (`itemtype`), + + CONSTRAINT `circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE, KEY `rule_name` (`rule_name`), UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index e889d148ea..c4d47d2dfb 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4219,9 +4219,9 @@ CREATE TABLE `circulation_rules` ( `rule_name` varchar(32) NOT NULL, `rule_value` varchar(32) NOT NULL, PRIMARY KEY (`id`), - KEY `branchcode` (`branchcode`), - KEY `categorycode` (`categorycode`), - KEY `itemtype` (`itemtype`), + CONSTRAINT `circ_rules_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `circ_rules_ibfk_2` FOREIGN KEY (`categorycode`) REFERENCES `categories` (`categorycode`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `circ_rules_ibfk_3` FOREIGN KEY (`itemtype`) REFERENCES `itemtypes` (`itemtype`) ON DELETE CASCADE ON UPDATE CASCADE, KEY `rule_name` (`rule_name`), UNIQUE (`branchcode`,`categorycode`,`itemtype`,`rule_name`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.11.4.GIT