View | Details | Raw Unified | Return to bug 21946
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug_21946.perl (+20 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    unless ( column_exists('itemtypes', 'parent_type') ) {
4
        $dbh->do(q{
5
            ALTER TABLE itemtypes
6
                ADD COLUMN parent_type VARCHAR(10) NULL DEFAULT NULL
7
                AFTER itemtype;
8
9
        });
10
    }
11
    unless ( foreign_key_exists( 'itemtypes', 'itemtypes_ibfk_1') ){
12
        $dbh->do(q{
13
            ALTER TABLE itemtypes
14
            ADD CONSTRAINT itemtypes_ibfk_1
15
            FOREIGN KEY (parent_type) REFERENCES itemtypes (itemtype)
16
        });
17
    }
18
    SetVersion( $DBversion );
19
    print "Upgrade to $DBversion done (Bug 21946 - Add parent type to itemtypes)\n";
20
}
(-)a/installer/data/mysql/kohastructure.sql (-1 / +2 lines)
Lines 920-925 CREATE TABLE `items` ( -- holdings/item information Link Here
920
DROP TABLE IF EXISTS `itemtypes`;
920
DROP TABLE IF EXISTS `itemtypes`;
921
CREATE TABLE `itemtypes` ( -- defines the item types
921
CREATE TABLE `itemtypes` ( -- defines the item types
922
  itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
922
  itemtype varchar(10) NOT NULL default '', -- unique key, a code associated with the item type
923
  parent_type varchar(10) NULL default NULL, -- unique key, a code associated with the item type
923
  description LONGTEXT, -- a plain text explanation of the item type
924
  description LONGTEXT, -- a plain text explanation of the item type
924
  rentalcharge decimal(28,6) default NULL, -- the amount charged when this item is checked out/issued
925
  rentalcharge decimal(28,6) default NULL, -- the amount charged when this item is checked out/issued
925
  rentalcharge_daily decimal(28,6) default NULL, -- the amount charged for each day between checkout date and due date
926
  rentalcharge_daily decimal(28,6) default NULL, -- the amount charged for each day between checkout date and due date
Lines 935-940 CREATE TABLE `itemtypes` ( -- defines the item types Link Here
935
  hideinopac tinyint(1) NOT NULL DEFAULT 0, -- Hide the item type from the search options in OPAC
936
  hideinopac tinyint(1) NOT NULL DEFAULT 0, -- Hide the item type from the search options in OPAC
936
  searchcategory varchar(80) default NULL, -- Group this item type with others with the same value on OPAC search options
937
  searchcategory varchar(80) default NULL, -- Group this item type with others with the same value on OPAC search options
937
  PRIMARY KEY  (`itemtype`),
938
  PRIMARY KEY  (`itemtype`),
939
  FOREIGN KEY (parent_type) REFERENCES itemtypes(itemtype) ON UPDATE CASCADE ON DELETE CASCADE,
938
  UNIQUE KEY `itemtype` (`itemtype`)
940
  UNIQUE KEY `itemtype` (`itemtype`)
939
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
941
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
940
942
941
- 

Return to bug 21946