From 6669080fc5c76d990730c481ea4edfb1ae89c0b8 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 30 Aug 2016 11:55:52 +0100 Subject: [PATCH] Bug 17216: Add FK on authorised_values.category Signed-off-by: Owen Leonard --- installer/data/mysql/atomicupdate/bug_17216_1_add_table.sql | 2 ++ installer/data/mysql/kohastructure.sql | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/installer/data/mysql/atomicupdate/bug_17216_1_add_table.sql b/installer/data/mysql/atomicupdate/bug_17216_1_add_table.sql index cc5ac6e..07dcb83 100644 --- a/installer/data/mysql/atomicupdate/bug_17216_1_add_table.sql +++ b/installer/data/mysql/atomicupdate/bug_17216_1_add_table.sql @@ -45,3 +45,5 @@ ALTER TABLE items_search_fields DROP FOREIGN KEY items_search_fields_authorised_values_category; ALTER TABLE items_search_fields ADD CONSTRAINT `items_search_fields_authorised_values_category` FOREIGN KEY (`authorised_values_category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE authorised_values + ADD CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index 3ab77e1..356f195 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -118,7 +118,8 @@ CREATE TABLE `authorised_values` ( -- stores values for authorized values catego PRIMARY KEY (`id`), KEY `name` (`category`), KEY `lib` (`lib`), - KEY `auth_value_idx` (`authorised_value`) + KEY `auth_value_idx` (`authorised_value`), + CONSTRAINT `authorised_values_authorised_values_category` FOREIGN KEY (`category`) REFERENCES `authorised_value_categories` (`category_name`) ON DELETE CASCADE ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- -- 2.8.1