Bug 31569: DB update and objects

Signed-off-by: Andrew Fuerste-Henry <andrewfh@dubcolib.org>

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2022-09-15 12:42:56 +00:00 committed by Tomas Cohen Arazi
parent b04e8185a3
commit 0a2d2f7810
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
5 changed files with 130 additions and 0 deletions

View File

@ -22,6 +22,7 @@ use MARC::Record;
use C4::Context;
use Koha::Database;
use Koha::Import::Record::Biblios;
use base qw(Koha::Object);
@ -56,6 +57,20 @@ sub get_marc_record {
return $record;
}
=head3 import_biblio
Returns the import biblio object for this import record
my $import_biblio = $import_record->import_biblio()
=cut
sub import_biblio {
my ( $self ) = @_;
my $import_biblio_rs = $self->_result->import_biblio;
return Koha::Import::Record::Biblio->_new_from_dbic( $import_biblio_rs );
}
=head2 Internal methods
=head3 _type

View File

@ -0,0 +1,44 @@
package Koha::Import::Record::Biblio;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Carp;
use Koha::Database;
use base qw(Koha::Object);
=head1 NAME
Koha::Import::Record::Biblio - Koha Import Record Biblio Object class
=head1 API
=head2 Internal methods
=head3 _type
Returns name of corresponding DBIC resultset
=cut
sub _type {
return 'ImportBiblio';
}
1;

View File

@ -0,0 +1,56 @@
package Koha::Import::Record::Biblios;
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Carp;
use Koha::Database;
use Koha::Import::Record::Biblio;
use base qw(Koha::Objects);
=head1 NAME
Koha::Import::Record::Biblios - Koha Import Record Biblios Object set class
=head1 API
=head2 Class Methods
=cut
=head3 type
=cut
sub _type {
return 'ImportBiblio';
}
=head3 object_class
Koha::Object class
=cut
sub object_class {
return 'Koha::Import::Record::Biblio';
}
1;

View File

@ -0,0 +1,14 @@
use Modern::Perl;
return {
bug_number => "31569",
description => "Add primary key for import_biblios",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
unless( primary_key_exists('import_biblios') ){
$dbh->do(q{ALTER TABLE import_biblios ADD PRIMARY KEY (import_record_id)});
say $out "Added primary key to import_biblios table";
}
},
};

View File

@ -3052,6 +3052,7 @@ CREATE TABLE `import_biblios` (
`isbn` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`issn` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`has_items` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`import_record_id`),
KEY `import_biblios_ibfk_1` (`import_record_id`),
KEY `matched_biblionumber` (`matched_biblionumber`),
KEY `title` (`title`(191)),