Bug 22368: DBRev 18.12.00.024

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Nick Clemens 2019-03-11 13:03:37 +00:00
parent b701ceae34
commit c3f28829e5
7 changed files with 313 additions and 97 deletions

View File

@ -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.023";
$VERSION = "18.12.00.024";
sub version {
return $VERSION;

View File

@ -302,6 +302,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 suggestions
Type: has_many
Related object: L<Koha::Schema::Result::Suggestion>
=cut
__PACKAGE__->has_many(
"suggestions",
"Koha::Schema::Result::Suggestion",
{ "foreign.biblionumber" => "self.biblionumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 tags_all
Type: has_many
@ -348,7 +363,7 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bUv00JjY09Hj2Zj4klqyxA
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-11 12:56:41
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ebn7Szfm8/HbrdAc7ekTnA
1;

View File

@ -1315,6 +1315,66 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 suggestions_acceptedbies
Type: has_many
Related object: L<Koha::Schema::Result::Suggestion>
=cut
__PACKAGE__->has_many(
"suggestions_acceptedbies",
"Koha::Schema::Result::Suggestion",
{ "foreign.acceptedby" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 suggestions_managedbies
Type: has_many
Related object: L<Koha::Schema::Result::Suggestion>
=cut
__PACKAGE__->has_many(
"suggestions_managedbies",
"Koha::Schema::Result::Suggestion",
{ "foreign.managedby" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 suggestions_rejectedbies
Type: has_many
Related object: L<Koha::Schema::Result::Suggestion>
=cut
__PACKAGE__->has_many(
"suggestions_rejectedbies",
"Koha::Schema::Result::Suggestion",
{ "foreign.rejectedby" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 suggestions_suggestedbies
Type: has_many
Related object: L<Koha::Schema::Result::Suggestion>
=cut
__PACKAGE__->has_many(
"suggestions_suggestedbies",
"Koha::Schema::Result::Suggestion",
{ "foreign.suggestedby" => "self.borrowernumber" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 tags_all
Type: has_many
@ -1446,8 +1506,8 @@ Composing rels: L</aqorder_users> -> ordernumber
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-02-15 13:15:09
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:NhuG8jv9ut+qIIm3vGHsrQ
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-11 12:56:41
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:F/j4bsmnxc2Cja5DKfMseQ
__PACKAGE__->belongs_to(
"guarantor",

View File

@ -631,6 +631,21 @@ __PACKAGE__->has_many(
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 suggestions
Type: has_many
Related object: L<Koha::Schema::Result::Suggestion>
=cut
__PACKAGE__->has_many(
"suggestions",
"Koha::Schema::Result::Suggestion",
{ "foreign.branchcode" => "self.branchcode" },
{ cascade_copy => 0, cascade_delete => 0 },
);
=head2 transport_cost_frombranches
Type: has_many
@ -662,8 +677,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-05 20:42:53
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nArzlMOpUO6oVOAZUgzSRg
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-11 12:56:41
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pKohWwsuUHcZSlGDj7zmcw
__PACKAGE__->add_columns(
'+pickup_location' => { is_boolean => 1 }

View File

@ -32,8 +32,8 @@ __PACKAGE__->table("suggestions");
=head2 suggestedby
data_type: 'integer'
default_value: 0
is_nullable: 0
is_foreign_key: 1
is_nullable: 1
=head2 suggesteddate
@ -44,6 +44,7 @@ __PACKAGE__->table("suggestions");
=head2 managedby
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 manageddate
@ -55,6 +56,7 @@ __PACKAGE__->table("suggestions");
=head2 acceptedby
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 accepteddate
@ -66,6 +68,7 @@ __PACKAGE__->table("suggestions");
=head2 rejectedby
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 rejecteddate
@ -144,6 +147,7 @@ __PACKAGE__->table("suggestions");
=head2 biblionumber
data_type: 'integer'
is_foreign_key: 1
is_nullable: 1
=head2 reason
@ -165,6 +169,7 @@ __PACKAGE__->table("suggestions");
=head2 branchcode
data_type: 'varchar'
is_foreign_key: 1
is_nullable: 1
size: 10
@ -208,19 +213,19 @@ __PACKAGE__->add_columns(
"suggestionid",
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 },
"suggestedby",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"suggesteddate",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 0 },
"managedby",
{ data_type => "integer", is_nullable => 1 },
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"manageddate",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
"acceptedby",
{ data_type => "integer", is_nullable => 1 },
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"accepteddate",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
"rejectedby",
{ data_type => "integer", is_nullable => 1 },
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"rejecteddate",
{ data_type => "date", datetime_undef_if_invalid => 1, is_nullable => 1 },
"STATUS",
@ -257,7 +262,7 @@ __PACKAGE__->add_columns(
"isbn",
{ data_type => "varchar", is_nullable => 1, size => 30 },
"biblionumber",
{ data_type => "integer", is_nullable => 1 },
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"reason",
{ data_type => "mediumtext", is_nullable => 1 },
"patronreason",
@ -265,7 +270,7 @@ __PACKAGE__->add_columns(
"budgetid",
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"branchcode",
{ data_type => "varchar", is_nullable => 1, size => 10 },
{ data_type => "varchar", is_foreign_key => 1, is_nullable => 1, size => 10 },
"collectiontitle",
{ data_type => "mediumtext", is_nullable => 1 },
"itemtype",
@ -294,6 +299,66 @@ __PACKAGE__->set_primary_key("suggestionid");
=head1 RELATIONS
=head2 acceptedby
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"acceptedby",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "acceptedby" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=head2 biblionumber
Type: belongs_to
Related object: L<Koha::Schema::Result::Biblio>
=cut
__PACKAGE__->belongs_to(
"biblionumber",
"Koha::Schema::Result::Biblio",
{ biblionumber => "biblionumber" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=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 budgetid
Type: belongs_to
@ -314,9 +379,69 @@ __PACKAGE__->belongs_to(
},
);
=head2 managedby
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:54
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dOt4/U4rLcXq+aACRwcpYw
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"managedby",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "managedby" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=head2 rejectedby
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"rejectedby",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "rejectedby" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
=head2 suggestedby
Type: belongs_to
Related object: L<Koha::Schema::Result::Borrower>
=cut
__PACKAGE__->belongs_to(
"suggestedby",
"Koha::Schema::Result::Borrower",
{ borrowernumber => "suggestedby" },
{
is_deferrable => 1,
join_type => "LEFT",
on_delete => "SET NULL",
on_update => "CASCADE",
},
);
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-11 12:56:41
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UsG/gxLa0HMMbcpbscV29Q
# You can replace this text with custom content, and it will be preserved on regeneration

View File

@ -1,80 +0,0 @@
$DBversion = 'XXX'; # will be replaced by the RM
if ( CheckVersion($DBversion) ) {
# Add constraint for suggestedby
unless ( foreign_key_exists( 'suggestions', 'suggestions_ibfk_suggestedby' ) )
{
$dbh->do(
"ALTER TABLE suggestions CHANGE COLUMN suggestedby suggestedby INT(11) NULL DEFAULT NULL;"
);
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.suggestedby = borrowers.borrowernumber) SET suggestedby = null WHERE borrowernumber IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_suggestedby` FOREIGN KEY (`suggestedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for managedby
unless ( foreign_key_exists( 'suggestions', 'suggestions_ibfk_managedby' ) )
{
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.managedby = borrowers.borrowernumber) SET managedby = null WHERE borrowernumber IS NULL"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_managedby` FOREIGN KEY (`managedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for acceptedby
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_acceptedby' ) )
{
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.acceptedby = borrowers.borrowernumber) SET acceptedby = null WHERE borrowernumber IS NULL"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_acceptedby` FOREIGN KEY (`acceptedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for rejectedby
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_rejectedby' ) )
{
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.rejectedby = borrowers.borrowernumber) SET rejectedby = null WHERE borrowernumber IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_rejectedby` FOREIGN KEY (`rejectedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for biblionumber
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_biblionumber' ) )
{
$dbh->do(
"UPDATE suggestions s LEFT JOIN biblio b ON (s.biblionumber = b.biblionumber) SET s.biblionumber = null WHERE b.biblionumber IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for branchcode
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_branchcode' ) )
{
$dbh->do(
"UPDATE suggestions s LEFT JOIN branches b ON (s.branchcode = b.branchcode) SET s.branchcode = null WHERE b.branchcode IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
SetVersion($DBversion);
print
"Upgrade to $DBversion done (Bug 22368 - Add missing constraints to suggestions)\n";
}

View File

@ -17609,6 +17609,87 @@ if( CheckVersion( $DBversion ) ) {
print "Upgrade to $DBversion done (Bug 20639 - Add ILLOpacbackends syspref)\n";
}
$DBversion = '18.12.00.024';
if ( CheckVersion($DBversion) ) {
# Add constraint for suggestedby
unless ( foreign_key_exists( 'suggestions', 'suggestions_ibfk_suggestedby' ) )
{
$dbh->do(
"ALTER TABLE suggestions CHANGE COLUMN suggestedby suggestedby INT(11) NULL DEFAULT NULL;"
);
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.suggestedby = borrowers.borrowernumber) SET suggestedby = null WHERE borrowernumber IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_suggestedby` FOREIGN KEY (`suggestedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for managedby
unless ( foreign_key_exists( 'suggestions', 'suggestions_ibfk_managedby' ) )
{
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.managedby = borrowers.borrowernumber) SET managedby = null WHERE borrowernumber IS NULL"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_managedby` FOREIGN KEY (`managedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for acceptedby
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_acceptedby' ) )
{
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.acceptedby = borrowers.borrowernumber) SET acceptedby = null WHERE borrowernumber IS NULL"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_acceptedby` FOREIGN KEY (`acceptedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for rejectedby
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_rejectedby' ) )
{
$dbh->do(
"UPDATE suggestions LEFT JOIN borrowers ON (suggestions.rejectedby = borrowers.borrowernumber) SET rejectedby = null WHERE borrowernumber IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_rejectedby` FOREIGN KEY (`rejectedby`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for biblionumber
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_biblionumber' ) )
{
$dbh->do(
"UPDATE suggestions s LEFT JOIN biblio b ON (s.biblionumber = b.biblionumber) SET s.biblionumber = null WHERE b.biblionumber IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_biblionumber` FOREIGN KEY (`biblionumber`) REFERENCES `biblio` (`biblionumber`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
# Add constraint for branchcode
unless (
foreign_key_exists( 'suggestions', 'suggestions_ibfk_branchcode' ) )
{
$dbh->do(
"UPDATE suggestions s LEFT JOIN branches b ON (s.branchcode = b.branchcode) SET s.branchcode = null WHERE b.branchcode IS null"
);
$dbh->do(
"ALTER TABLE suggestions ADD CONSTRAINT `suggestions_ibfk_branchcode` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE SET NULL ON UPDATE CASCADE"
);
}
SetVersion($DBversion);
print
"Upgrade to $DBversion done (Bug 22368 - Add missing constraints to suggestions)\n";
}
# SEE bug 13068
# if there is anything in the atomicupdate, read and execute it.