Bug 26145: DB changes - Add biblioimages.imagenumber

Sponsored-by: Gerhard Sondermann Dialog e.K. (presseplus.de, presseshop.at, presseshop.ch)

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2020-07-28 21:13:01 +02:00
parent 62a569ea73
commit ff17013a65
2 changed files with 24 additions and 2 deletions

View file

@ -0,0 +1,20 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if( !column_exists( 'biblioimages', 'itemnumber' ) ) {
$dbh->do(q|
ALTER TABLE biblioimages
ADD COLUMN itemnumber INT(11) DEFAULT NULL
AFTER biblionumber;
|);
$dbh->do(q|
ALTER TABLE biblioimages
ADD FOREIGN KEY bibliocoverimage_fk2 (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
|);
$dbh->do(q|
ALTER TABLE biblioimages MODIFY biblionumber INT(11) DEFAULT NULL
|)
}
NewVersion( $DBversion, 'XXXXX', "Add the biblioimages.itemnumber column");
}

View file

@ -3374,13 +3374,15 @@ DROP TABLE IF EXISTS `biblioimages`;
CREATE TABLE `biblioimages` ( -- local cover images
`imagenumber` int(11) NOT NULL AUTO_INCREMENT, -- unique identifier for the image
`biblionumber` int(11) NOT NULL, -- foreign key from biblio table to link to biblionumber
`biblionumber` int(11) DEFAULT NULL, -- foreign key from biblio table to link to biblionumber
`itemnumber` int(11) DEFAULT NULL, -- foreign key from item table to link to itemnumber
`mimetype` varchar(15) NOT NULL, -- image type
`imagefile` mediumblob NOT NULL, -- image file contents
`thumbnail` mediumblob NOT NULL, -- thumbnail file contents
`timestamp` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- image creation/update time
PRIMARY KEY (`imagenumber`),
CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE
CONSTRAINT `bibliocoverimage_fk1` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `bibliocoverimage_fk2` FOREIGN KEY (`itemnumber`) REFERENCES `item` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--