From a5103cd396389fc57fa49de09a04a2bba9c9d9ad Mon Sep 17 00:00:00 2001
From: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Date: Thu, 18 Nov 2021 15:04:38 +0000
Subject: [PATCH] Bug 28854: Drop unique index on issue_id in return claims

With the introduction of circulating items within a bundle set, we can
now loose multiple items from the bundle from the same issue.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
---
 installer/data/mysql/atomicupdate/bug_28854.pl | 7 +++++++
 installer/data/mysql/kohastructure.sql         | 1 -
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/installer/data/mysql/atomicupdate/bug_28854.pl b/installer/data/mysql/atomicupdate/bug_28854.pl
index 381740e11e..d93fa9f49e 100644
--- a/installer/data/mysql/atomicupdate/bug_28854.pl
+++ b/installer/data/mysql/atomicupdate/bug_28854.pl
@@ -44,5 +44,12 @@ return {
               ( 'BundleNotLoanValue', $nfl_val, '', 'Sets the NOT_LOAN AV value that represents "Added to bundle" as a not for loan value', 'Free')
         });
         say $out "System preferences added and set";
+
+        if( index_exists( 'return_claims', 'issue_id' ) ) {
+            $dbh->do(q{
+                ALTER TABLE return_claims DROP INDEX issue_id
+            });
+            say $out "Dropped unique constraint on issue_id in return_claims";
+        }
     }
 }
diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql
index eb54838e5e..3227ab27f1 100644
--- a/installer/data/mysql/kohastructure.sql
+++ b/installer/data/mysql/kohastructure.sql
@@ -4514,7 +4514,6 @@ CREATE TABLE `return_claims` (
   `resolved_on` timestamp NULL DEFAULT NULL COMMENT 'Time and date the claim was resolved',
   `resolved_by` int(11) DEFAULT NULL COMMENT 'ID of the staff member that resolved the claim',
   PRIMARY KEY (`id`),
-  UNIQUE KEY `issue_id` (`issue_id`),
   KEY `itemnumber` (`itemnumber`),
   KEY `rc_borrowers_ibfk` (`borrowernumber`),
   KEY `rc_created_by_ibfk` (`created_by`),
-- 
2.20.1