1 $DBversion = 'XXX'; # will be replaced by the RM
2 if( CheckVersion( $DBversion ) ) {
3 if( !column_exists( 'biblio', 'subtitle' ) ) {
4 $dbh->do( "ALTER TABLE biblio ADD COLUMN medium LONGTEXT AFTER title" );
5 $dbh->do( "ALTER TABLE biblio ADD COLUMN subtitle LONGTEXT AFTER medium" );
6 $dbh->do( "ALTER TABLE biblio ADD COLUMN part_number LONGTEXT AFTER subtitle" );
7 $dbh->do( "ALTER TABLE biblio ADD COLUMN part_name LONGTEXT AFTER part_number" );
9 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN medium LONGTEXT AFTER title" );
10 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN subtitle LONGTEXT AFTER medium" );
11 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_number LONGTEXT AFTER subtitle" );
12 $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_name LONGTEXT AFTER part_number" );
15 $dbh->do( "UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' WHERE kohafield='bibliosubtitle.subtitle'" );
17 my $marcflavour = C4::Context->preference('marcflavour');
19 if ( $marcflavour eq 'UNIMARC' ) {
21 UPDATE marc_subfield_structure SET kohafield='biblio.medium'
22 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='b'
25 UPDATE marc_subfield_structure SET kohafield='biblio.subtitle'
26 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='e'
29 UPDATE marc_subfield_structure SET kohafield='biblio.part_number'
30 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='h'
33 UPDATE marc_subfield_structure SET kohafield='biblio.part_name'
34 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='i'
38 UPDATE marc_subfield_structure SET kohafield='biblio.medium'
39 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='h'
42 UPDATE marc_subfield_structure SET kohafield='biblio.subtitle'
43 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='b'
46 UPDATE marc_subfield_structure SET kohafield='biblio.part_number'
47 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='n'
50 UPDATE marc_subfield_structure SET kohafield='biblio.part_name'
51 WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='p'
55 $dbh->do("UPDATE marc_subfield_structure JOIN fieldmapping ON tagfield = fieldcode AND subfieldcode=tagsubfield SET kohafield='biblio.subtitle' WHERE fieldmapping.frameworkcode=''");
56 $sth = $dbh->prepare("SELECT * FROM fieldmapping WHERE frameworkcode != '' OR field != 'subtitle'");
58 print "Keyword to MARC mappings below cannot be preserved: \n" if $sth->rows;
59 while ( my $value = $sth->fetchrow_hashref() ){
60 my $framework = $value->{frameworkcode} eq "" ? "Default" : $value->{frameworkcode};
61 print " keyword: " . $value->{'field'} . " to field: " . $value->{fieldcode} . "\$" . $value->{subfieldcode} . " for $framework framework\n";
63 print "You will need to remap using Koha to MARC mappings in administration\n" if $sth->rows;
66 # $dbh->do( "DROP TABLE IF EXISTS fieldmapping" );
68 $dbh->do( "DELETE FROM user_permissions WHERE code='manage_keywords2koha_mappings'" );
70 $dbh->do( "DELETE FROM permissions WHERE code='manage_keywords2koha_mappings'" );
72 # Always end with this (adjust the bug info)
73 SetVersion( $DBversion );
74 print "Upgrade to $DBversion done (Bug 11529 - Add medium, subtitle and part information to biblio table)\n";