Bug 14978

Summary: issues.itemnumber should be a unique key
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Architecture, internals, and plumbingAssignee: Jonathan Druart <jonathan.druart>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: normal    
Priority: P5 - low CC: barton, f.demians, katrin.fischer, theod, tomascohen, veron
Version: master   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=13790
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15677
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=16534
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 14069    
Bug Blocks: 15462, 16534    
Attachments: Bug 14978: Add unique key constraint on issues.itemnumber
Bug 14978: Add unique key constraint on issues.itemnumber
[PASSED QA] Bug 14978: Add unique key constraint on issues.itemnumber

Description Jonathan Druart 2015-10-08 07:52:10 UTC
Bug 14069 removed existing primary key on issues without questioning why one could exist.
Note that the primary key was not in the kohastructure.sql and only existed on old DB.

issues.itemnumber should be a unique key to avoid duplication of issues on the same item.
Comment 1 Jonathan Druart 2015-10-08 08:19:09 UTC Comment hidden (obsolete)
Comment 2 Marc Véron 2015-10-12 15:29:58 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall 2015-10-30 18:18:13 UTC
Created attachment 44246 [details] [review]
[PASSED QA] Bug 14978: Add unique key constraint on issues.itemnumber

The constraint might have existed before bug 14069.
For these DB, this patch will restore it, for others, it will add it :)

Test plan:
> show create table issues;
should not return "unique key itemnumber"
Execute the updatedb entry twice
> show create table issues;
should return only one "unique key itemnumber"

Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Tomás Cohen Arazi 2015-11-02 16:05:19 UTC
Patch pushed to master.

Thanks Jonathan!
Comment 5 Frédéric Demians 2015-11-27 06:52:03 UTC
Does this patch need to be backported to 3.20.x?
Comment 6 Jonathan Druart 2015-12-01 09:50:36 UTC
(In reply to Frédéric Demians from comment #5)
> Does this patch need to be backported to 3.20.x?

As bug 14069 is in 3.20.x I would say yes.
Comment 7 Frédéric Demians 2015-12-02 07:57:18 UTC
This patch has been pushed to 3.20.x, will be in 3.20.7.
Comment 8 Katrin Fischer 2015-12-02 22:32:36 UTC
Do we need to change the database update statements in later versions now to avoid errors/warnings?
Comment 9 Katrin Fischer 2015-12-02 22:33:31 UTC
Ah, I see it already includes a check for existence - so should be safe :)
Comment 10 Jonathan Druart 2016-02-15 17:37:20 UTC
*** Bug 15677 has been marked as a duplicate of this bug. ***