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> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
cb5d44e2f1
commit
0e0f3e4946
2 changed files with 18 additions and 1 deletions
17
installer/data/mysql/atomicupdate/bug18427.perl
Normal file
17
installer/data/mysql/atomicupdate/bug18427.perl
Normal file
|
@ -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";
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue