Bugzilla – Attachment 62382 Details for
Bug 18427
Add a primary key to serialitems
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18427: Add a primary key to serialitems
Bug-18427-Add-a-primary-key-to-serialitems.patch (text/plain), 2.47 KB, created by
Jonathan Druart
on 2017-04-19 14:45:57 UTC
(
hide
)
Description:
Bug 18427: Add a primary key to serialitems
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2017-04-19 14:45:57 UTC
Size:
2.47 KB
patch
obsolete
>From 1dacf12030ef591a5c8ce902c093134e0eb266e1 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Thu, 13 Apr 2017 13:34:36 +0200 >Subject: [PATCH] Bug 18427: Add a primary key to serialitems > >We drop the unique index serialitemsidx and add a primary key consisting >of itemnumber just as the unique key did. > >Test plan: >Run the db revision. >Apply bug 18182. The TestBuilder.t should no longer fail on serialitems. > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > installer/data/mysql/atomicupdate/bug18427.perl | 17 +++++++++++++++++ > installer/data/mysql/kohastructure.sql | 2 +- > 2 files changed, 18 insertions(+), 1 deletion(-) > create mode 100644 installer/data/mysql/atomicupdate/bug18427.perl > >diff --git a/installer/data/mysql/atomicupdate/bug18427.perl b/installer/data/mysql/atomicupdate/bug18427.perl >new file mode 100644 >index 0000000..a77a948 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug18427.perl >@@ -0,0 +1,17 @@ >+$DBversion = 'XXX'; # will be replaced by the RM >+if( CheckVersion( $DBversion ) ) { >+ >+ # In order to be overcomplete, we check if the situation is what we expect >+ if( !index_exists( 'serialitems', 'PRIMARY' ) ) { >+ if( index_exists( 'serialitems', 'serialitemsidx' ) ) { >+ $dbh->do(q| >+ALTER TABLE serialitems ADD PRIMARY KEY (itemnumber), DROP INDEX serialitemsidx; >+ |); >+ } else { >+ $dbh->do(q|ALTER TABLE serialitems ADD PRIMARY KEY (itemnumber)|); >+ } >+ } >+ >+ SetVersion( $DBversion ); >+ print "Upgrade to $DBversion done (Bug 18427 - Add a primary key to serialitems)\n"; >+} >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 261fb37..857de55 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -2441,7 +2441,7 @@ DROP TABLE IF EXISTS `serialitems`; > CREATE TABLE `serialitems` ( > `itemnumber` int(11) NOT NULL, > `serialid` int(11) NOT NULL, >- UNIQUE KEY `serialitemsidx` (`itemnumber`), >+ PRIMARY KEY (`itemnumber`), > KEY `serialitems_sfk_1` (`serialid`), > CONSTRAINT `serialitems_sfk_1` FOREIGN KEY (`serialid`) REFERENCES `serial` (`serialid`) ON DELETE CASCADE ON UPDATE CASCADE, > CONSTRAINT `serialitems_sfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE >-- >2.9.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 18427
:
62144
|
62145
|
62146
|
62147
|
62365
|
62366
|
62381
| 62382