--- /dev/null
+package Koha::Import::Record::Auth;
+
+# 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::Auth - Koha Import Record Authority Object class
+
+=head1 API
+
+=head2 Internal methods
+
+=head3 _type
+
+Returns name of corresponding DBIC resultset
+
+=cut
+
+sub _type {
+ return 'ImportAuth';
+}
+
+1;
--- /dev/null
+package Koha::Import::Record::Auths;
+
+# 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 Koha::Import::Record::Auth;
+
+use base qw(Koha::Objects);
+
+=head1 NAME
+
+Koha::Import::Record::Auths - Koha Import Record Auths Object set class
+
+=head1 API
+
+=head2 Class Methods
+
+=cut
+
+=head3 type
+
+=cut
+
+sub _type {
+ return 'ImportAuth';
+}
+
+=head3 object_class
+
+Koha::Object class
+
+=cut
+
+sub object_class {
+ return 'Koha::Import::Record::Auth';
+}
+
+1;
--- /dev/null
+use Modern::Perl;
+
+return {
+ bug_number => "32437",
+ description => "Add primary key to import_auths tables",
+ up => sub {
+ my ($args) = @_;
+ my ($dbh, $out) = @$args{qw(dbh out)};
+ if( !primary_key_exists('import_auths') ){
+ $dbh->do(q{ALTER TABLE import_auths ADD PRIMARY KEY (import_record_id);});
+ say $out "Added PRIMARY KEY ON import_record_id to import_authd table";
+ } elsif( !primary_key_exists('import_auths','import_record_id') ){
+ say $out "Found an existing PRIMARY KEY on import_auths table";
+ say $out "You must delete this key and replace it with a key on import_record_id";
+ } else {
+ say $out "PRIMARY KEY import_record_id on import_auths already exists";
+ }
+ },
+};
`control_number` varchar(25) DEFAULT NULL,
`authorized_heading` varchar(128) DEFAULT NULL,
`original_source` varchar(25) DEFAULT NULL,
+ PRIMARY KEY (`import_record_id`),
KEY `import_auths_ibfk_1` (`import_record_id`),
KEY `matched_authid` (`matched_authid`),
CONSTRAINT `import_auths_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright 2020 Koha Development team
+#
+# 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 Test::More tests => 3;
+
+use Koha::Import::Record::Auths;
+use Koha::Database;
+
+use t::lib::TestBuilder;
+
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
+my $builder = t::lib::TestBuilder->new;
+my $nb_of_record_auths = Koha::Import::Record::Auths->search->count;
+
+my $record_auth_1 = $builder->build({ source => 'ImportAuth' });
+my $record_auth_2 = $builder->build({ source => 'ImportAuth' });
+
+is( Koha::Import::Record::Auths->search->count, $nb_of_record_auths + 2, 'The 2 record auths should have been added' );
+
+my $retrieved_record_auth_1 = Koha::Import::Record::Auths->search({ import_record_id => $record_auth_1->{import_record_id}})->next;
+is_deeply( $retrieved_record_auth_1->unblessed, $record_auth_1, 'Find a record auth by import record id should return the correct record auth' );
+
+$retrieved_record_auth_1->delete;
+is( Koha::Import::Record::Auths->search->count, $nb_of_record_auths + 1, 'Delete should have deleted the record auth' );
+
+$schema->storage->txn_rollback;
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright 2020 Koha Development team
+#
+# 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 Test::More tests => 3;
+
+use Koha::Import::Record::Biblios;
+use Koha::Database;
+
+use t::lib::TestBuilder;
+
+my $schema = Koha::Database->new->schema;
+$schema->storage->txn_begin;
+
+my $builder = t::lib::TestBuilder->new;
+my $nb_of_record_biblios = Koha::Import::Record::Biblios->search->count;
+
+my $record_biblio_1 = $builder->build({ source => 'ImportBiblio' });
+my $record_biblio_2 = $builder->build({ source => 'ImportBiblio' });
+
+is( Koha::Import::Record::Biblios->search->count, $nb_of_record_biblios + 2, 'The 2 record biblios should have been added' );
+
+my $retrieved_record_biblio_1 = Koha::Import::Record::Biblios->search({ import_record_id => $record_biblio_1->{import_record_id}})->next;
+is_deeply( $retrieved_record_biblio_1->unblessed, $record_biblio_1, 'Find a record biblio by import record id should return the correct record biblio' );
+
+$retrieved_record_biblio_1->delete;
+is( Koha::Import::Record::Biblios->search->count, $nb_of_record_biblios + 1, 'Delete should have deleted the record biblio' );
+
+$schema->storage->txn_rollback;