Browse Source

Bug 19066: DBRev 18.12.00.004

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
19.05.x
Nick Clemens 6 years ago
parent
commit
224718b3ad
  1. 2
      Koha.pm
  2. 33
      Koha/Schema/Result/Accountline.pm
  3. 19
      Koha/Schema/Result/Branch.pm
  4. 12
      installer/data/mysql/atomicupdate/bug_19066_add_accountlines_branchcode.perl
  5. 10
      installer/data/mysql/updatedatabase.pl

2
Koha.pm

@ -29,7 +29,7 @@ use vars qw{ $VERSION };
# - #4 : the developer version. The 4th number is the database subversion.
# used by developers when the database changes. updatedatabase take care of the changes itself
# and is automatically called by Auth.pm when needed.
$VERSION = "18.12.00.003";
$VERSION = "18.12.00.004";
sub version {
return $VERSION;

33
Koha/Schema/Result/Accountline.pm

@ -110,6 +110,13 @@ __PACKAGE__->table("accountlines");
data_type: 'integer'
is_nullable: 1
=head2 branchcode
data_type: 'varchar'
is_foreign_key: 1
is_nullable: 1
size: 10
=cut
__PACKAGE__->add_columns(
@ -148,6 +155,8 @@ __PACKAGE__->add_columns(
{ data_type => "mediumtext", is_nullable => 1 },
"manager_id",
{ data_type => "integer", is_nullable => 1 },
"branchcode",
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
);
=head1 PRIMARY KEY
@ -214,6 +223,26 @@ __PACKAGE__->belongs_to(
},
);
=head2 branchcode
Type: belongs_to
Related object: L<Koha::Schema::Result::Branch>
=cut
__PACKAGE__->belongs_to(
"branchcode",
"Koha::Schema::Result::Branch",
{ branchcode => "branchcode" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=head2 itemnumber
Type: belongs_to
@ -235,8 +264,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-12-19 16:19:16
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kvBIJshNRsm/HYJBbhm0IA
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-03 16:10:04
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BO7iSB+QzoJNuZ8Uttba6A
sub koha_objects_class {
'Koha::Account::Lines';

19
Koha/Schema/Result/Branch.pm

@ -211,6 +211,21 @@ __PACKAGE__->set_primary_key("branchcode");
=head1 RELATIONS
=head2 accountlines
Type: has_many
Related object: L<Koha::Schema::Result::Accountline>
=cut
__PACKAGE__->has_many(
"accountlines",
"Koha::Schema::Result::Accountline",
{ "foreign.branchcode" => "self.branchcode" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 aqbaskets
Type: has_many
@ -662,8 +677,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-09 15:50:42
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0yMUX1UukdV7eMol06JXTQ
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-03 16:10:04
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WyXH3sMlyuJIx0fd31RswA
# You can replace this text with custom code or comments, and it will be preserved on regeneration

12
installer/data/mysql/atomicupdate/bug_19066_add_accountlines_branchcode.perl

@ -1,12 +0,0 @@
$DBversion = 'XXX'; # will be replaced by the RM
if( CheckVersion( $DBversion ) ) {
if( !column_exists( 'accountlines', 'branchcode' ) ) {
$dbh->do("ALTER TABLE accountlines ADD branchcode VARCHAR( 10 ) NULL DEFAULT NULL AFTER manager_id");
$dbh->do("ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_branches FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE");
}
# Always end with this (adjust the bug info)
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 19066 - Add branchcode to accountlines)\n";
}

10
installer/data/mysql/updatedatabase.pl

@ -17205,6 +17205,16 @@ if( CheckVersion( $DBversion ) ) {
print "Upgrade to $DBversion done (Bug 22024 - Add missing splitting rule definitions)\n";
}
$DBversion = '18.12.00.004';
if( CheckVersion( $DBversion ) ) {
if( !column_exists( 'accountlines', 'branchcode' ) ) {
$dbh->do("ALTER TABLE accountlines ADD branchcode VARCHAR( 10 ) NULL DEFAULT NULL AFTER manager_id");
$dbh->do("ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_branches FOREIGN KEY (branchcode) REFERENCES branches (branchcode) ON DELETE SET NULL ON UPDATE CASCADE");
}
SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 19066 - Add branchcode to accountlines)\n";
}
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.

Loading…
Cancel
Save