From 7bcf1c98d376aefd43b743979769526b045c4e90 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 3 Feb 2016 14:38:54 +0000 Subject: [PATCH] Bug 15675 [QA Followup] - Close out accruing fines that are not really accruing, add issue_id to accruing fines --- installer/data/mysql/atomicupdate/bug_15334.sql | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/installer/data/mysql/atomicupdate/bug_15334.sql b/installer/data/mysql/atomicupdate/bug_15334.sql index 7937e81..bc38127 100644 --- a/installer/data/mysql/atomicupdate/bug_15334.sql +++ b/installer/data/mysql/atomicupdate/bug_15334.sql @@ -1 +1,8 @@ +-- Add issue_id to accountlines table ALTER TABLE accountlines ADD issue_id INT(11) NULL DEFAULT NULL AFTER accountlines_id; + +-- Close out any unclosed fines, keep only the latest fine unclosed +UPDATE accountlines SET accounttype = 'F' WHERE accountlines_id NOT IN ( SELECT accountlines_id FROM ( SELECT * FROM accountlines WHERE accounttype = 'FU' ORDER BY accountlines_id DESC ) a2 GROUP BY borrowernumber, itemnumber ); + +-- Update the unclosed fines to add the current issue_id to them +UPDATE accountlines LEFT JOIN issues USING ( itemnumber ) SET accountlines.issue_id = issues.issue_id WHERE accounttype = 'FU'; -- 2.1.4