From b5ccfefa0d7f2d90aa06a81a167d35bff8141e51 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Tue, 13 Aug 2019 13:28:26 -0300 Subject: [PATCH] Bug 14570: Add a UNIQUE constraint on guarantor_id+guarantee_id Signed-off-by: Tomas Cohen Arazi Signed-off-by: Kyle M Hall --- installer/data/mysql/atomicupdate/bug_14570.perl | 1 + installer/data/mysql/kohastructure.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_14570.perl b/installer/data/mysql/atomicupdate/bug_14570.perl index 967fd34a21..c266c9b669 100644 --- a/installer/data/mysql/atomicupdate/bug_14570.perl +++ b/installer/data/mysql/atomicupdate/bug_14570.perl @@ -10,6 +10,7 @@ if( CheckVersion( $DBversion ) ) { guarantee_id INT(11) NOT NULL, relationship VARCHAR(100) NOT NULL, PRIMARY KEY (id), + UNIQUE KEY `guarantor_guarantee_idx` ( `guarantor_id`, `guarantee_id` ), CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql index d28822ca0a..cd7d7dfbcc 100644 --- a/installer/data/mysql/kohastructure.sql +++ b/installer/data/mysql/kohastructure.sql @@ -4080,6 +4080,7 @@ CREATE TABLE `borrower_relationships` ( guarantee_id INT(11) NOT NULL, relationship VARCHAR(100) NOT NULL, PRIMARY KEY (id), + UNIQUE KEY `guarantor_guarantee_idx` ( `guarantor_id`, `guarantee_id` ), CONSTRAINT r_guarantor FOREIGN KEY ( guarantor_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE, CONSTRAINT r_guarantee FOREIGN KEY ( guarantee_id ) REFERENCES borrowers ( borrowernumber ) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; -- 2.20.1 (Apple Git-117)