View | Details | Raw Unified | Return to bug 32437
Collapse All | Expand All

(-)a/Koha/Import/Record/Auth.pm (+44 lines)
Line 0 Link Here
1
package Koha::Import::Record::Auth;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Import::Record::Auth - Koha Import Record Authority Object class
29
30
=head1 API
31
32
=head2 Internal methods
33
34
=head3 _type
35
36
Returns name of corresponding DBIC resultset
37
38
=cut
39
40
sub _type {
41
    return 'ImportAuth';
42
}
43
44
1;
(-)a/Koha/Import/Record/Auths.pm (+52 lines)
Line 0 Link Here
1
package Koha::Import::Record::Auths;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Koha::Import::Record::Auth;
21
22
use base qw(Koha::Objects);
23
24
=head1 NAME
25
26
Koha::Import::Record::Auths - Koha Import Record Auths Object set class
27
28
=head1 API
29
30
=head2 Class Methods
31
32
=cut
33
34
=head3 type
35
36
=cut
37
38
sub _type {
39
    return 'ImportAuth';
40
}
41
42
=head3 object_class
43
44
Koha::Object class
45
46
=cut
47
48
sub object_class {
49
    return 'Koha::Import::Record::Auth';
50
}
51
52
1;
(-)a/Koha/Schema/Result/ImportAuth.pm (-3 / +20 lines)
Lines 67-72 __PACKAGE__->add_columns( Link Here
67
  { data_type => "varchar", is_nullable => 1, size => 25 },
67
  { data_type => "varchar", is_nullable => 1, size => 25 },
68
);
68
);
69
69
70
=head1 PRIMARY KEY
71
72
=over 4
73
74
=item * L</import_record_id>
75
76
=back
77
78
=cut
79
80
__PACKAGE__->set_primary_key("import_record_id");
81
70
=head1 RELATIONS
82
=head1 RELATIONS
71
83
72
=head2 import_record
84
=head2 import_record
Lines 85-93 __PACKAGE__->belongs_to( Link Here
85
);
97
);
86
98
87
99
88
# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21
100
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-12-12 12:33:40
89
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bm1ctlmYDh4qWUU95SLqBw
101
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3XmbG33SxiC0v4jj6V4bfQ
90
102
103
sub koha_object_class {
104
    'Koha::Import::Record::Auth';
105
}
106
sub koha_objects_class {
107
    'Koha::Import::Record::Auths';
108
}
91
109
92
# You can replace this text with custom content, and it will be preserved on regeneration
93
1;
110
1;
(-)a/Koha/Schema/Result/ImportRecord.pm (-6 / +6 lines)
Lines 186-201 __PACKAGE__->set_primary_key("import_record_id"); Link Here
186
186
187
=head1 RELATIONS
187
=head1 RELATIONS
188
188
189
=head2 import_auths
189
=head2 import_auth
190
190
191
Type: has_many
191
Type: might_have
192
192
193
Related object: L<Koha::Schema::Result::ImportAuth>
193
Related object: L<Koha::Schema::Result::ImportAuth>
194
194
195
=cut
195
=cut
196
196
197
__PACKAGE__->has_many(
197
__PACKAGE__->might_have(
198
  "import_auths",
198
  "import_auth",
199
  "Koha::Schema::Result::ImportAuth",
199
  "Koha::Schema::Result::ImportAuth",
200
  { "foreign.import_record_id" => "self.import_record_id" },
200
  { "foreign.import_record_id" => "self.import_record_id" },
201
  { cascade_copy => 0, cascade_delete => 0 },
201
  { cascade_copy => 0, cascade_delete => 0 },
Lines 262-269 __PACKAGE__->has_many( Link Here
262
);
262
);
263
263
264
264
265
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-10-17 11:17:50
265
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-12-12 12:33:40
266
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bGhtHdQ7/pXWWezcgz/4EA
266
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:OEpfDFkYGGgTowPIly5bYQ
267
267
268
sub koha_object_class {
268
sub koha_object_class {
269
    'Koha::Import::Record';
269
    'Koha::Import::Record';
(-)a/installer/data/mysql/atomicupdate/bug_32437.pl (+19 lines)
Line 0 Link Here
1
use Modern::Perl;
2
3
return {
4
    bug_number => "32437",
5
    description => "Add primary key to import_auths tables",
6
    up => sub {
7
        my ($args) = @_;
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
        if( !primary_key_exists('import_auths') ){
10
            $dbh->do(q{ALTER TABLE import_auths ADD PRIMARY KEY (import_record_id);});
11
            say $out "Added PRIMARY KEY ON import_record_id to import_authd table";
12
        } elsif( !primary_key_exists('import_auths','import_record_id') ){
13
            say $out "Found an existing PRIMARY KEY on import_auths table";
14
            say $out "You must delete this key and replace it with a key on import_record_id";
15
        } else {
16
            say $out "PRIMARY KEY import_record_id on import_auths already exists";
17
        }
18
    },
19
};
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 3281-3286 CREATE TABLE `import_auths` ( Link Here
3281
  `control_number` varchar(25) DEFAULT NULL,
3281
  `control_number` varchar(25) DEFAULT NULL,
3282
  `authorized_heading` varchar(128) DEFAULT NULL,
3282
  `authorized_heading` varchar(128) DEFAULT NULL,
3283
  `original_source` varchar(25) DEFAULT NULL,
3283
  `original_source` varchar(25) DEFAULT NULL,
3284
  PRIMARY KEY (`import_record_id`),
3284
  KEY `import_auths_ibfk_1` (`import_record_id`),
3285
  KEY `import_auths_ibfk_1` (`import_record_id`),
3285
  KEY `matched_authid` (`matched_authid`),
3286
  KEY `matched_authid` (`matched_authid`),
3286
  CONSTRAINT `import_auths_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
3287
  CONSTRAINT `import_auths_ibfk_1` FOREIGN KEY (`import_record_id`) REFERENCES `import_records` (`import_record_id`) ON DELETE CASCADE ON UPDATE CASCADE
(-)a/t/db_dependent/Koha/Import/Record/Auths.t (+46 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2020 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 3;
23
24
use Koha::Import::Record::Auths;
25
use Koha::Database;
26
27
use t::lib::TestBuilder;
28
29
my $schema = Koha::Database->new->schema;
30
$schema->storage->txn_begin;
31
32
my $builder = t::lib::TestBuilder->new;
33
my $nb_of_record_auths = Koha::Import::Record::Auths->search->count;
34
35
my $record_auth_1 = $builder->build({ source => 'ImportAuth' });
36
my $record_auth_2 = $builder->build({ source => 'ImportAuth' });
37
38
is( Koha::Import::Record::Auths->search->count, $nb_of_record_auths + 2, 'The 2 record auths should have been added' );
39
40
my $retrieved_record_auth_1 = Koha::Import::Record::Auths->search({ import_record_id => $record_auth_1->{import_record_id}})->next;
41
is_deeply( $retrieved_record_auth_1->unblessed, $record_auth_1, 'Find a record auth by import record id should return the correct record auth' );
42
43
$retrieved_record_auth_1->delete;
44
is( Koha::Import::Record::Auths->search->count, $nb_of_record_auths + 1, 'Delete should have deleted the record auth' );
45
46
$schema->storage->txn_rollback;
(-)a/t/db_dependent/Koha/Import/Record/Biblios.t (-1 / +46 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2020 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 3;
23
24
use Koha::Import::Record::Biblios;
25
use Koha::Database;
26
27
use t::lib::TestBuilder;
28
29
my $schema = Koha::Database->new->schema;
30
$schema->storage->txn_begin;
31
32
my $builder = t::lib::TestBuilder->new;
33
my $nb_of_record_biblios = Koha::Import::Record::Biblios->search->count;
34
35
my $record_biblio_1 = $builder->build({ source => 'ImportBiblio' });
36
my $record_biblio_2 = $builder->build({ source => 'ImportBiblio' });
37
38
is( Koha::Import::Record::Biblios->search->count, $nb_of_record_biblios + 2, 'The 2 record biblios should have been added' );
39
40
my $retrieved_record_biblio_1 = Koha::Import::Record::Biblios->search({ import_record_id => $record_biblio_1->{import_record_id}})->next;
41
is_deeply( $retrieved_record_biblio_1->unblessed, $record_biblio_1, 'Find a record biblio by import record id should return the correct record biblio' );
42
43
$retrieved_record_biblio_1->delete;
44
is( Koha::Import::Record::Biblios->search->count, $nb_of_record_biblios + 1, 'Delete should have deleted the record biblio' );
45
46
$schema->storage->txn_rollback;

Return to bug 32437