@@ -, +, @@ --- C4/Biblio.pm | 6 +++--- Koha/MetadataRecord/History.pm | 4 ++-- installer/data/mysql/atomicupdate/add_history.sql | 1 - .../data/mysql/atomicupdate/bug_14367_-_add_history_column.perl | 9 +++++++++ 4 files changed, 14 insertions(+), 6 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/add_history.sql create mode 100644 installer/data/mysql/atomicupdate/bug_14367_-_add_history_column.perl --- a/C4/Biblio.pm +++ a/C4/Biblio.pm @@ -301,7 +301,7 @@ sub ModBiblio { # update biblionumber and biblioitemnumber in MARC # FIXME - this is assuming a 1 to 1 relationship between # biblios and biblioitems - my $sth = $dbh->prepare("select biblioitemnumber,history from biblioitems where biblionumber=?"); + my $sth = $dbh->prepare("select biblioitems.biblioitemnumber, biblio_metadata.history from biblioitems, biblio_metadata where biblioitems.biblionumber=?"); $sth->execute($biblionumber); my ($biblioitemnumber, $history) = $sth->fetchrow; $sth->finish(); @@ -3363,8 +3363,8 @@ sub ModBiblioMarc { my $newhistory = HistoryUpdate($newrecord, $historylength, $history); $newhistory = encode_json($newhistory); - $sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=?,history=? WHERE biblionumber=?"); - $sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $newhistory, $biblionumber ); + $sth = $dbh->prepare("UPDATE biblio_metadata SET metadata=?,history=? WHERE biblionumber=?"); + $sth->execute( $record->as_xml_record($encoding), $newhistory, $biblionumber ); $sth->finish; ModZebra( $biblionumber, "specialUpdate", "biblioserver", $record ); --- a/Koha/MetadataRecord/History.pm +++ a/Koha/MetadataRecord/History.pm @@ -68,10 +68,10 @@ sub GetMarcBiblioHistory { return; } my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("SELECT marcxml,history FROM biblioitems WHERE biblionumber=? "); + my $sth = $dbh->prepare("SELECT metadata,history FROM biblio_metadata WHERE biblionumber=? "); $sth->execute($biblionumber); my $row = $sth->fetchrow_hashref; - my $marcxml = StripNonXmlChars( $row->{'marcxml'} ); + my $marcxml = StripNonXmlChars( $row->{'metadata'} ); MARC::File::XML->default_record_format( C4::Context->preference('marcflavour') ); my $record = MARC::Record->new(); my ($history, $borrowers) = HistoryParse( $row->{'history'} ); --- a/installer/data/mysql/atomicupdate/add_history.sql +++ a/installer/data/mysql/atomicupdate/add_history.sql @@ -1, +0,0 @@ -ALTER TABLE biblioitems ADD COLUMN `history` LONGTEXT DEFAULT NULL AFTER `marcxml`; --- a/installer/data/mysql/atomicupdate/bug_14367_-_add_history_column.perl +++ a/installer/data/mysql/atomicupdate/bug_14367_-_add_history_column.perl @@ -0,0 +1,9 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + unless( column_exists( 'biblio_metadata', 'history' ) ) { + $dbh->do(q|ALTER TABLE biblio_metadata ADD history longtext default NULL AFTER metadata|); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 14367: Add column biblio_metadata.history)\n"; +} --