From 7883eb0692b15fdc453437cc595bf1903fa4540b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Mon, 5 Aug 2019 14:36:55 +0100 Subject: [PATCH] Bug 11529: DBRev 19.06.00.018 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- Koha/Schema/Result/Biblio.pm | 8 +- Koha/Schema/Result/Deletedbiblio.pm | 32 +++++++- .../data/mysql/atomicupdate/bug_11529.perl | 75 ------------------ installer/data/mysql/updatedatabase.pl | 76 +++++++++++++++++++ 5 files changed, 111 insertions(+), 82 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_11529.perl diff --git a/Koha.pm b/Koha.pm index 4fb19e726e..5e93d9be22 100644 --- a/Koha.pm +++ b/Koha.pm @@ -29,7 +29,7 @@ use vars qw{ $VERSION }; # - #4 : the developer version. The 4th number is the database subversion. # used by developers when the database changes. updatedatabase take care of the changes itself # and is automatically called by Auth.pm when needed. -$VERSION = "19.06.00.017"; +$VERSION = "19.06.00.018"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/Biblio.pm b/Koha/Schema/Result/Biblio.pm index 4f78e735c6..9674b56fe6 100644 --- a/Koha/Schema/Result/Biblio.pm +++ b/Koha/Schema/Result/Biblio.pm @@ -95,7 +95,7 @@ __PACKAGE__->table("biblio"); data_type: 'timestamp' datetime_undef_if_invalid: 1 - default_value: 'current_timestamp()' + default_value: current_timestamp is_nullable: 0 =head2 datecreated @@ -142,7 +142,7 @@ __PACKAGE__->add_columns( { data_type => "timestamp", datetime_undef_if_invalid => 1, - default_value => "current_timestamp()", + default_value => \"current_timestamp", is_nullable => 0, }, "datecreated", @@ -391,8 +391,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2019-03-15 16:45:45 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:61+Di/Fke60nCaASGeXbvw +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-08-05 13:53:34 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AzvuQItPPs5WeC4tdtS/NQ __PACKAGE__->has_one( diff --git a/Koha/Schema/Result/Deletedbiblio.pm b/Koha/Schema/Result/Deletedbiblio.pm index f809b9324d..a502d26a18 100644 --- a/Koha/Schema/Result/Deletedbiblio.pm +++ b/Koha/Schema/Result/Deletedbiblio.pm @@ -46,6 +46,26 @@ __PACKAGE__->table("deletedbiblio"); data_type: 'longtext' is_nullable: 1 +=head2 medium + + data_type: 'longtext' + is_nullable: 1 + +=head2 subtitle + + data_type: 'longtext' + is_nullable: 1 + +=head2 part_number + + data_type: 'longtext' + is_nullable: 1 + +=head2 part_name + + data_type: 'longtext' + is_nullable: 1 + =head2 unititle data_type: 'longtext' @@ -100,6 +120,14 @@ __PACKAGE__->add_columns( { data_type => "longtext", is_nullable => 1 }, "title", { data_type => "longtext", is_nullable => 1 }, + "medium", + { data_type => "longtext", is_nullable => 1 }, + "subtitle", + { data_type => "longtext", is_nullable => 1 }, + "part_number", + { data_type => "longtext", is_nullable => 1 }, + "part_name", + { data_type => "longtext", is_nullable => 1 }, "unititle", { data_type => "longtext", is_nullable => 1 }, "notes", @@ -153,8 +181,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dP0HOIp/+I93Y/u92TDI1g +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-08-05 13:53:34 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:FQaznWmkfR2Ge5NG8lDmSw # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/bug_11529.perl b/installer/data/mysql/atomicupdate/bug_11529.perl deleted file mode 100644 index 034821ddc6..0000000000 --- a/installer/data/mysql/atomicupdate/bug_11529.perl +++ /dev/null @@ -1,75 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - if( !column_exists( 'biblio', 'subtitle' ) ) { - $dbh->do( "ALTER TABLE biblio ADD COLUMN medium LONGTEXT AFTER title" ); - $dbh->do( "ALTER TABLE biblio ADD COLUMN subtitle LONGTEXT AFTER medium" ); - $dbh->do( "ALTER TABLE biblio ADD COLUMN part_number LONGTEXT AFTER subtitle" ); - $dbh->do( "ALTER TABLE biblio ADD COLUMN part_name LONGTEXT AFTER part_number" ); - - $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN medium LONGTEXT AFTER title" ); - $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN subtitle LONGTEXT AFTER medium" ); - $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_number LONGTEXT AFTER subtitle" ); - $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_name LONGTEXT AFTER part_number" ); - } - - $dbh->do( "UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' WHERE kohafield='bibliosubtitle.subtitle'" ); - - my $marcflavour = C4::Context->preference('marcflavour'); - - if ( $marcflavour eq 'UNIMARC' ) { - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.medium' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='b' - }); - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='e' - }); - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.part_number' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='h' - }); - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.part_name' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='i' - }); - } else { - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.medium' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='h' - }); - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='b' - }); - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.part_number' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='n' - }); - $dbh->do(qq{ - UPDATE marc_subfield_structure SET kohafield='biblio.part_name' - WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='p' - }); - } - - $dbh->do("UPDATE marc_subfield_structure JOIN fieldmapping ON tagfield = fieldcode AND subfieldcode=tagsubfield SET kohafield='biblio.subtitle' WHERE fieldmapping.frameworkcode=''"); - $sth = $dbh->prepare("SELECT * FROM fieldmapping WHERE frameworkcode != '' OR field != 'subtitle'"); - $sth->execute; - print "Keyword to MARC mappings below cannot be preserved: \n" if $sth->rows; - while ( my $value = $sth->fetchrow_hashref() ){ - my $framework = $value->{frameworkcode} eq "" ? "Default" : $value->{frameworkcode}; - print " keyword: " . $value->{'field'} . " to field: " . $value->{fieldcode} . "\$" . $value->{subfieldcode} . " for $framework framework\n"; - } - print "You will need to remap using Koha to MARC mappings in administration\n" if $sth->rows; - - -# $dbh->do( "DROP TABLE IF EXISTS fieldmapping" ); - - $dbh->do( "DELETE FROM user_permissions WHERE code='manage_keywords2koha_mappings'" ); - - $dbh->do( "DELETE FROM permissions WHERE code='manage_keywords2koha_mappings'" ); - - # Always end with this (adjust the bug info) - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 11529 - Add medium, subtitle and part information to biblio table)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 45f81e796e..e75420223b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -19144,6 +19144,82 @@ if ( CheckVersion($DBversion) ) { print "Upgrade to $DBversion done (Bug 22610 - Fix accounttypes for SIP2 payments)\n"; } +$DBversion = '19.06.00.018'; +if( CheckVersion( $DBversion ) ) { + if( !column_exists( 'biblio', 'subtitle' ) ) { + $dbh->do( "ALTER TABLE biblio ADD COLUMN medium LONGTEXT AFTER title" ); + $dbh->do( "ALTER TABLE biblio ADD COLUMN subtitle LONGTEXT AFTER medium" ); + $dbh->do( "ALTER TABLE biblio ADD COLUMN part_number LONGTEXT AFTER subtitle" ); + $dbh->do( "ALTER TABLE biblio ADD COLUMN part_name LONGTEXT AFTER part_number" ); + + $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN medium LONGTEXT AFTER title" ); + $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN subtitle LONGTEXT AFTER medium" ); + $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_number LONGTEXT AFTER subtitle" ); + $dbh->do( "ALTER TABLE deletedbiblio ADD COLUMN part_name LONGTEXT AFTER part_number" ); + } + + $dbh->do( "UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' WHERE kohafield='bibliosubtitle.subtitle'" ); + + my $marcflavour = C4::Context->preference('marcflavour'); + + if ( $marcflavour eq 'UNIMARC' ) { + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.medium' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='b' + }); + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='e' + }); + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.part_number' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='h' + }); + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.part_name' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='200' AND tagsubfield='i' + }); + } else { + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.medium' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='h' + }); + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.subtitle' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='b' + }); + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.part_number' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='n' + }); + $dbh->do(qq{ + UPDATE marc_subfield_structure SET kohafield='biblio.part_name' + WHERE (kohafield IS NULL OR kohafield='') AND frameworkcode='' AND tagfield='245' AND tagsubfield='p' + }); + } + + $dbh->do("UPDATE marc_subfield_structure JOIN fieldmapping ON tagfield = fieldcode AND subfieldcode=tagsubfield SET kohafield='biblio.subtitle' WHERE fieldmapping.frameworkcode=''"); + $sth = $dbh->prepare("SELECT * FROM fieldmapping WHERE frameworkcode != '' OR field != 'subtitle'"); + $sth->execute; + print "Keyword to MARC mappings below cannot be preserved: \n" if $sth->rows; + while ( my $value = $sth->fetchrow_hashref() ){ + my $framework = $value->{frameworkcode} eq "" ? "Default" : $value->{frameworkcode}; + print " keyword: " . $value->{'field'} . " to field: " . $value->{fieldcode} . "\$" . $value->{subfieldcode} . " for $framework framework\n"; + } + print "You will need to remap using Koha to MARC mappings in administration\n" if $sth->rows; + + + $dbh->do( "DROP TABLE IF EXISTS fieldmapping" ); + + $dbh->do( "DELETE FROM user_permissions WHERE code='manage_keywords2koha_mappings'" ); + + $dbh->do( "DELETE FROM permissions WHERE code='manage_keywords2koha_mappings'" ); + + # Always end with this (adjust the bug info) + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 11529 - Add medium, subtitle and part information to biblio table)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.39.5