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

(-)a/Koha/Schema/Result/Borrower.pm (-2 / +32 lines)
Lines 1157-1162 __PACKAGE__->has_many( Link Here
1157
  { cascade_copy => 0, cascade_delete => 0 },
1157
  { cascade_copy => 0, cascade_delete => 0 },
1158
);
1158
);
1159
1159
1160
=head2 issues_issuers
1161
1162
Type: has_many
1163
1164
Related object: L<Koha::Schema::Result::Issue>
1165
1166
=cut
1167
1168
__PACKAGE__->has_many(
1169
  "issues_issuers",
1170
  "Koha::Schema::Result::Issue",
1171
  { "foreign.issuer_id" => "self.borrowernumber" },
1172
  { cascade_copy => 0, cascade_delete => 0 },
1173
);
1174
1160
=head2 items_last_borrowers
1175
=head2 items_last_borrowers
1161
1176
1162
Type: has_many
1177
Type: has_many
Lines 1232-1237 __PACKAGE__->has_many( Link Here
1232
  { cascade_copy => 0, cascade_delete => 0 },
1247
  { cascade_copy => 0, cascade_delete => 0 },
1233
);
1248
);
1234
1249
1250
=head2 old_issues_issuers
1251
1252
Type: has_many
1253
1254
Related object: L<Koha::Schema::Result::OldIssue>
1255
1256
=cut
1257
1258
__PACKAGE__->has_many(
1259
  "old_issues_issuers",
1260
  "Koha::Schema::Result::OldIssue",
1261
  { "foreign.issuer_id" => "self.borrowernumber" },
1262
  { cascade_copy => 0, cascade_delete => 0 },
1263
);
1264
1235
=head2 old_reserves
1265
=head2 old_reserves
1236
1266
1237
Type: has_many
1267
Type: has_many
Lines 1683-1690 Composing rels: L</aqorder_users> -> ordernumber Link Here
1683
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1713
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1684
1714
1685
1715
1686
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-10-08 14:17:29
1716
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-09 19:12:25
1687
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kzx7ildKCEFF6YDr6MRCrw
1717
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Kp53XFs7tFIpzNSqm/WY8w
1688
1718
1689
__PACKAGE__->add_columns(
1719
__PACKAGE__->add_columns(
1690
    '+anonymized'    => { is_boolean => 1 },
1720
    '+anonymized'    => { is_boolean => 1 },
(-)a/Koha/Schema/Result/Issue.pm (-2 / +30 lines)
Lines 35-40 __PACKAGE__->table("issues"); Link Here
35
  is_foreign_key: 1
35
  is_foreign_key: 1
36
  is_nullable: 1
36
  is_nullable: 1
37
37
38
=head2 issuer_id
39
40
  data_type: 'integer'
41
  is_foreign_key: 1
42
  is_nullable: 1
43
38
=head2 itemnumber
44
=head2 itemnumber
39
45
40
  data_type: 'integer'
46
  data_type: 'integer'
Lines 125-130 __PACKAGE__->add_columns( Link Here
125
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
131
  { data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
126
  "borrowernumber",
132
  "borrowernumber",
127
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
133
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
134
  "issuer_id",
135
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
128
  "itemnumber",
136
  "itemnumber",
129
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
137
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
130
  "date_due",
138
  "date_due",
Lines 228-233 __PACKAGE__->belongs_to( Link Here
228
  },
236
  },
229
);
237
);
230
238
239
=head2 issuer
240
241
Type: belongs_to
242
243
Related object: L<Koha::Schema::Result::Borrower>
244
245
=cut
246
247
__PACKAGE__->belongs_to(
248
  "issuer",
249
  "Koha::Schema::Result::Borrower",
250
  { borrowernumber => "issuer_id" },
251
  {
252
    is_deferrable => 1,
253
    join_type     => "LEFT",
254
    on_delete     => "SET NULL",
255
    on_update     => "CASCADE",
256
  },
257
);
258
231
=head2 itemnumber
259
=head2 itemnumber
232
260
233
Type: belongs_to
261
Type: belongs_to
Lines 264-271 __PACKAGE__->might_have( Link Here
264
);
292
);
265
293
266
294
267
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-31 12:18:38
295
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-09 19:12:26
268
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QVmFa5b0Pe5OhUI92n9kzQ
296
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Z0qpsT632VLwejUFjIO/ag
269
297
270
__PACKAGE__->add_columns(
298
__PACKAGE__->add_columns(
271
    '+auto_renew'      => { is_boolean => 1 },
299
    '+auto_renew'      => { is_boolean => 1 },
(-)a/Koha/Schema/Result/OldIssue.pm (-2 / +30 lines)
Lines 34-39 __PACKAGE__->table("old_issues"); Link Here
34
  is_foreign_key: 1
34
  is_foreign_key: 1
35
  is_nullable: 1
35
  is_nullable: 1
36
36
37
=head2 issuer_id
38
39
  data_type: 'integer'
40
  is_foreign_key: 1
41
  is_nullable: 1
42
37
=head2 itemnumber
43
=head2 itemnumber
38
44
39
  data_type: 'integer'
45
  data_type: 'integer'
Lines 124-129 __PACKAGE__->add_columns( Link Here
124
  { data_type => "integer", is_nullable => 0 },
130
  { data_type => "integer", is_nullable => 0 },
125
  "borrowernumber",
131
  "borrowernumber",
126
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
132
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
133
  "issuer_id",
134
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
127
  "itemnumber",
135
  "itemnumber",
128
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
136
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
129
  "date_due",
137
  "date_due",
Lines 213-218 __PACKAGE__->belongs_to( Link Here
213
  },
221
  },
214
);
222
);
215
223
224
=head2 issuer
225
226
Type: belongs_to
227
228
Related object: L<Koha::Schema::Result::Borrower>
229
230
=cut
231
232
__PACKAGE__->belongs_to(
233
  "issuer",
234
  "Koha::Schema::Result::Borrower",
235
  { borrowernumber => "issuer_id" },
236
  {
237
    is_deferrable => 1,
238
    join_type     => "LEFT",
239
    on_delete     => "SET NULL",
240
    on_update     => "CASCADE",
241
  },
242
);
243
216
=head2 itemnumber
244
=head2 itemnumber
217
245
218
Type: belongs_to
246
Type: belongs_to
Lines 234-241 __PACKAGE__->belongs_to( Link Here
234
);
262
);
235
263
236
264
237
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-04-10 19:55:44
265
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-09 19:12:26
238
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A
266
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jlgsHwZKoVn/HJD1NP1gqg
239
267
240
__PACKAGE__->add_columns(
268
__PACKAGE__->add_columns(
241
    '+auto_renew'      => { is_boolean => 1 },
269
    '+auto_renew'      => { is_boolean => 1 },
(-)a/installer/data/mysql/atomicupdate/bug_23916_add_issues_issuer.perl (-6 / +5 lines)
Lines 1-18 Link Here
1
$DBversion = 'XXX'; # will be replaced by the RM
1
$DBversion = 'XXX'; # will be replaced by the RM
2
if( CheckVersion( $DBversion ) ) {
2
if( CheckVersion( $DBversion ) ) {
3
    if( !column_exists( 'issues', 'issuer' ) ) {
3
    if( !column_exists( 'issues', 'issuer' ) ) {
4
        $dbh->do( q| ALTER TABLE issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | );
4
        $dbh->do( q| ALTER TABLE issues ADD issuer_id INT(11) DEFAULT NULL AFTER borrowernumber | );
5
    }
5
    }
6
    if (!foreign_key_exists( 'issues', 'issues_ibfk_borrowers_borrowernumber' )) {
6
    if (!foreign_key_exists( 'issues', 'issues_ibfk_borrowers_borrowernumber' )) {
7
        $dbh->do( q| ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | );
7
        $dbh->do( q| ALTER TABLE issues ADD CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | );
8
    }
8
    }
9
    if( !column_exists( 'old_issues', 'issuer' ) ) {
9
    if( !column_exists( 'old_issues', 'issuer' ) ) {
10
        $dbh->do( q| ALTER TABLE old_issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | );
10
        $dbh->do( q| ALTER TABLE old_issues ADD issuer_id INT(11) DEFAULT NULL AFTER borrowernumber | );
11
    }
11
    }
12
    if (!foreign_key_exists( 'old_issues', 'old_issues_ibfk_borrowers_borrowernumber' )) {
12
    if (!foreign_key_exists( 'old_issues', 'old_issues_ibfk_borrowers_borrowernumber' )) {
13
        $dbh->do( q| ALTER TABLE old_issues ADD CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | );
13
        $dbh->do( q| ALTER TABLE old_issues ADD CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE | );
14
    }
14
    }
15
15
16
    SetVersion( $DBversion );
16
    NewVersion( $DBversion, 23916, "Add issues.issuer";
17
    print "Upgrade to $DBversion done (Bug 23916 - Add issues.issuer)\n";
18
}
17
}
(-)a/installer/data/mysql/kohastructure.sql (-5 / +4 lines)
Lines 1618-1624 DROP TABLE IF EXISTS `issues`; Link Here
1618
CREATE TABLE `issues` ( -- information related to check outs or issues
1618
CREATE TABLE `issues` ( -- information related to check outs or issues
1619
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1619
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
1620
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1620
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1621
  `issuer` int(11) default NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
1621
  `issuer_id` INT(11) NULL DEFAULT NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
1622
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1622
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
1623
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1623
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
1624
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1624
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
Lines 1641-1647 CREATE TABLE `issues` ( -- information related to check outs or issues Link Here
1641
  KEY `bordate` (`borrowernumber`,`timestamp`),
1641
  KEY `bordate` (`borrowernumber`,`timestamp`),
1642
  CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1642
  CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1643
  CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1643
  CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
1644
  CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
1644
  CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
1645
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1645
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1646
1646
1647
--
1647
--
Lines 1652-1658 DROP TABLE IF EXISTS `old_issues`; Link Here
1652
CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
1652
CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
1653
  `issue_id` int(11) NOT NULL, -- primary key for issues table
1653
  `issue_id` int(11) NOT NULL, -- primary key for issues table
1654
  `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1654
  `borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
1655
  `issuer` int(11) default NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
1655
  `issuer_id` INT(11) NULL DEFAULT NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
1656
  `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
1656
  `itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
1657
  `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
1657
  `date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
1658
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
1658
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
Lines 1676-1682 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r Link Here
1676
    ON DELETE SET NULL ON UPDATE SET NULL,
1676
    ON DELETE SET NULL ON UPDATE SET NULL,
1677
  CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1677
  CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
1678
    ON DELETE SET NULL ON UPDATE SET NULL,
1678
    ON DELETE SET NULL ON UPDATE SET NULL,
1679
  CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`)
1679
  CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`)
1680
    ON DELETE SET NULL ON UPDATE CASCADE
1680
    ON DELETE SET NULL ON UPDATE CASCADE
1681
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1681
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1682
1682
1683
- 

Return to bug 23916