Bug 23916: (QA follow-up) Rename issuer => issuer_id [DB]

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Tomás Cohen Arazi 2020-11-10 08:46:18 -03:00 committed by Jonathan Druart
parent 2de7a4c04e
commit aebf7f2756
5 changed files with 101 additions and 16 deletions

View file

@ -1157,6 +1157,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 issues_issuers
Type: has_many
Related object: L<Koha::Schema::Result::Issue>
=cut
__PACKAGE__->has_many(
"issues_issuers",
"Koha::Schema::Result::Issue",
{ "foreign.issuer_id" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 items_last_borrowers
Type: has_many
@ -1232,6 +1247,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 old_issues_issuers
Type: has_many
Related object: L<Koha::Schema::Result::OldIssue>
=cut
__PACKAGE__->has_many(
"old_issues_issuers",
"Koha::Schema::Result::OldIssue",
{ "foreign.issuer_id" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 old_reserves
Type: has_many
@ -1683,8 +1713,8 @@ Composing rels: L</aqorder_users> -> ordernumber
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
# Created by DBIx::Class::Schema::Loader v0.07049 @ 2020-10-08 14:17:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kzx7ildKCEFF6YDr6MRCrw
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-09 19:12:25
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Kp53XFs7tFIpzNSqm/WY8w
__PACKAGE__->add_columns(
'+anonymized' => { is_boolean => 1 },

View file

@ -35,6 +35,12 @@ __PACKAGE__->table("issues");
is_foreign_key: 1
is_nullable: 1
=head2 issuer_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 itemnumber
data_type: 'integer'
@ -125,6 +131,8 @@ __PACKAGE__->add_columns(
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"borrowernumber",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"issuer_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"itemnumber",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"date_due",
@ -228,6 +236,26 @@ __PACKAGE__->belongs_to(
},
);
=head2 issuer
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"issuer",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "issuer_id" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=head2 itemnumber
Type: belongs_to
@ -264,8 +292,8 @@ __PACKAGE__->might_have(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-31 12:18:38
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QVmFa5b0Pe5OhUI92n9kzQ
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-09 19:12:26
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Z0qpsT632VLwejUFjIO/ag
__PACKAGE__->add_columns(
'+auto_renew' => { is_boolean => 1 },

View file

@ -34,6 +34,12 @@ __PACKAGE__->table("old_issues");
is_foreign_key: 1
is_nullable: 1
=head2 issuer_id
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 itemnumber
data_type: 'integer'
@ -124,6 +130,8 @@ __PACKAGE__->add_columns(
{ data_type => "integer", is_nullable => 0 },
"borrowernumber",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"issuer_id",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"itemnumber",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"date_due",
@ -213,6 +221,26 @@ __PACKAGE__->belongs_to(
},
);
=head2 issuer
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"issuer",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "issuer_id" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=head2 itemnumber
Type: belongs_to
@ -234,8 +262,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-04-10 19:55:44
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2020-11-09 19:12:26
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jlgsHwZKoVn/HJD1NP1gqg
__PACKAGE__->add_columns(
'+auto_renew' => { is_boolean => 1 },

View file

@ -1,18 +1,17 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if( !column_exists( 'issues', 'issuer' ) ) {
$dbh->do( q| ALTER TABLE issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | );
$dbh->do( q| ALTER TABLE issues ADD issuer_id INT(11) DEFAULT NULL AFTER borrowernumber | );
}
if (!foreign_key_exists( 'issues', 'issues_ibfk_borrowers_borrowernumber' )) {
$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 | );
$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 | );
}
if( !column_exists( 'old_issues', 'issuer' ) ) {
$dbh->do( q| ALTER TABLE old_issues ADD issuer INT(11) DEFAULT NULL AFTER borrowernumber | );
$dbh->do( q| ALTER TABLE old_issues ADD issuer_id INT(11) DEFAULT NULL AFTER borrowernumber | );
}
if (!foreign_key_exists( 'old_issues', 'old_issues_ibfk_borrowers_borrowernumber' )) {
$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 | );
$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 | );
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 23916 - Add issues.issuer)\n";
NewVersion( $DBversion, 23916, "Add issues.issuer";
}

View file

@ -1618,7 +1618,7 @@ DROP TABLE IF EXISTS `issues`;
CREATE TABLE `issues` ( -- information related to check outs or issues
`issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
`borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
`issuer` int(11) default NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
`issuer_id` INT(11) NULL DEFAULT NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
`itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
`date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
`branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
@ -1641,7 +1641,7 @@ CREATE TABLE `issues` ( -- information related to check outs or issues
KEY `bordate` (`borrowernumber`,`timestamp`),
CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
CONSTRAINT `issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
@ -1652,7 +1652,7 @@ DROP TABLE IF EXISTS `old_issues`;
CREATE TABLE `old_issues` ( -- lists items that were checked out and have been returned
`issue_id` int(11) NOT NULL, -- primary key for issues table
`borrowernumber` int(11) default NULL, -- foreign key, linking this to the borrowers table for the patron this item was checked out to
`issuer` int(11) default NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
`issuer_id` INT(11) NULL DEFAULT NULL, -- foreign key, linking this to the borrowers table for the user who checked out this item
`itemnumber` int(11) default NULL, -- foreign key, linking this to the items table for the item that was checked out
`date_due` datetime default NULL, -- date the item is due (yyyy-mm-dd)
`branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
@ -1676,7 +1676,7 @@ CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r
ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `old_issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`)
ON DELETE SET NULL ON UPDATE SET NULL,
CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer`) REFERENCES `borrowers` (`borrowernumber`)
CONSTRAINT `old_issues_ibfk_borrowers_borrowernumber` FOREIGN KEY (`issuer_id`) REFERENCES `borrowers` (`borrowernumber`)
ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;