From eec93f0628d524f08860f0c727141e2e7c072d5b Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 31 Oct 2019 12:16:46 +0000 Subject: [PATCH] Bug 14697: DBRev 19.06.00.047 Signed-off-by: Martin Renvoize --- Koha.pm | 2 +- Koha/Schema/Result/Issue.pm | 19 +++++- Koha/Schema/Result/ReturnClaim.pm | 27 +++++++- .../data/mysql/atomicupdate/bug_14697.perl | 52 ---------------- installer/data/mysql/updatedatabase.pl | 62 +++++++++++++++++++ 5 files changed, 104 insertions(+), 58 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_14697.perl diff --git a/Koha.pm b/Koha.pm index 1e1dd7851d..ae8c2427f4 100644 --- a/Koha.pm +++ b/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 = "19.06.00.046"; +$VERSION = "19.06.00.047"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/Issue.pm b/Koha/Schema/Result/Issue.pm index ef1696e786..8bb16b6b92 100644 --- a/Koha/Schema/Result/Issue.pm +++ b/Koha/Schema/Result/Issue.pm @@ -248,9 +248,24 @@ __PACKAGE__->belongs_to( }, ); +=head2 return_claim -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-24 18:12:09 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:14iNqmSCD7OdcJMuZxbjpQ +Type: might_have + +Related object: L + +=cut + +__PACKAGE__->might_have( + "return_claim", + "Koha::Schema::Result::ReturnClaim", + { "foreign.issue_id" => "self.issue_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-31 12:18:38 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QVmFa5b0Pe5OhUI92n9kzQ __PACKAGE__->add_columns( '+auto_renew' => { is_boolean => 1 }, diff --git a/Koha/Schema/Result/ReturnClaim.pm b/Koha/Schema/Result/ReturnClaim.pm index 977e09e4dd..d3eb30141e 100644 --- a/Koha/Schema/Result/ReturnClaim.pm +++ b/Koha/Schema/Result/ReturnClaim.pm @@ -38,6 +38,7 @@ __PACKAGE__->table("return_claims"); =head2 issue_id data_type: 'integer' + is_foreign_key: 1 is_nullable: 1 =head2 borrowernumber @@ -101,7 +102,7 @@ __PACKAGE__->add_columns( "itemnumber", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "issue_id", - { data_type => "integer", is_nullable => 1 }, + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, "borrowernumber", { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, "notes", @@ -197,6 +198,26 @@ __PACKAGE__->belongs_to( }, ); +=head2 issue + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "issue", + "Koha::Schema::Result::Issue", + { issue_id => "issue_id" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "SET NULL", + on_update => "CASCADE", + }, +); + =head2 itemnumber Type: belongs_to @@ -253,8 +274,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-24 18:12:09 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ojrbFpQoVSmUMFJdNb6wTw +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-10-31 12:18:39 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a1MJxAPCP8yuYvzkXp5q8w # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/bug_14697.perl b/installer/data/mysql/atomicupdate/bug_14697.perl deleted file mode 100644 index 32bb97105b..0000000000 --- a/installer/data/mysql/atomicupdate/bug_14697.perl +++ /dev/null @@ -1,52 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - if( !TableExists( 'return_claims' ) ) { - $dbh->do(q{ - CREATE TABLE return_claims ( - id int(11) auto_increment, - itemnumber int(11) NOT NULL, - issue_id int(11) NULL DEFAULT NULL, - borrowernumber int(11) NOT NULL, - notes MEDIUMTEXT DEFAULT NULL, - created_on TIMESTAMP NULL, - created_by int(11) NULL DEFAULT NULL, - updated_on TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP, - updated_by int(11) NULL DEFAULT NULL, - resolution varchar(80) NULL DEFAULT NULL, - resolved_on TIMESTAMP NULL DEFAULT NULL, - resolved_by int(11) NULL DEFAULT NULL, - PRIMARY KEY (`id`), - KEY `itemnumber` (`itemnumber`), - CONSTRAINT UNIQUE `issue_id` ( issue_id ), - CONSTRAINT `issue_id` FOREIGN KEY (`issue_id`) REFERENCES `issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, - CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `rc_updated_by_ibfk` FOREIGN KEY (`updated_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, - CONSTRAINT `rc_resolved_by_ibfk` FOREIGN KEY (`resolved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; - }); - } - - $dbh->do(q{ - INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES - ('ClaimReturnedChargeFee', 'ask', 'ask|charge|no_charge', 'Controls whether or not a lost item fee is charged for return claims', 'Choice'), - ('ClaimReturnedLostValue', '', '', 'Sets the LOST AV value that represents "Claims returned" as a lost value', 'Free'), - ('ClaimReturnedWarningThreshold', '', '', 'Sets the number of return claims past which the librarian will be warned the patron has many return claims', 'Integer'); - }); - - $dbh->do(q{ - INSERT IGNORE INTO authorised_value_categories ( category_name ) VALUES - ('RETURN_CLAIM_RESOLUTION'); - }); - - $dbh->do(q{ - INSERT IGNORE INTO `authorised_values` ( category, authorised_value, lib ) - VALUES - ('RETURN_CLAIM_RESOLUTION', 'RET_BY_PATRON', 'Returned by patron'), - ('RETURN_CLAIM_RESOLUTION', 'FOUND_IN_LIB', 'Found in library'); - }); - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 14697 - Extend and enhance 'Claims returned' lost status)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index a63dc24f47..3e1675bb13 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -20127,6 +20127,68 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 15260 - Option for extended loan with useDaysMode)\n"; } +$DBversion = '19.06.00.047'; +if ( CheckVersion($DBversion) ) { + if ( !TableExists('return_claims') ) { + $dbh->do( + q{ + CREATE TABLE return_claims ( + id int(11) auto_increment, -- Unique ID of the return claim + itemnumber int(11) NOT NULL, -- ID of the item + issue_id int(11) NULL DEFAULT NULL, -- ID of the checkout that triggered the claim + borrowernumber int(11) NOT NULL, -- ID of the patron + notes MEDIUMTEXT DEFAULT NULL, -- Notes about the claim + created_on TIMESTAMP NULL, -- Time and date the claim was created + created_by int(11) NULL DEFAULT NULL, -- ID of the staff member that registered the claim + updated_on TIMESTAMP NULL ON UPDATE CURRENT_TIMESTAMP, -- Time and date of the latest change on the claim (notes) + updated_by int(11) NULL DEFAULT NULL, -- ID of the staff member that updated the claim + resolution varchar(80) NULL DEFAULT NULL, -- Resolution code (RETURN_CLAIM_RESOLUTION AVs) + resolved_on TIMESTAMP NULL DEFAULT NULL, -- Time and date the claim was resolved + resolved_by int(11) NULL DEFAULT NULL, -- ID of the staff member that resolved the claim + PRIMARY KEY (`id`), + KEY `itemnumber` (`itemnumber`), + CONSTRAINT UNIQUE `issue_id` ( issue_id ), + CONSTRAINT `issue_id` FOREIGN KEY (`issue_id`) REFERENCES `issues` (`issue_id`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `rc_items_ibfk` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `rc_borrowers_ibfk` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE CASCADE ON UPDATE CASCADE, + CONSTRAINT `rc_created_by_ibfk` FOREIGN KEY (`created_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `rc_updated_by_ibfk` FOREIGN KEY (`updated_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE, + CONSTRAINT `rc_resolved_by_ibfk` FOREIGN KEY (`resolved_by`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE SET NULL ON UPDATE CASCADE + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci; + } + ); + } + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('ClaimReturnedChargeFee', 'ask', 'ask|charge|no_charge', 'Controls whether or not a lost item fee is charged for return claims', 'Choice'), + ('ClaimReturnedLostValue', '', '', 'Sets the LOST AV value that represents "Claims returned" as a lost value', 'Free'), + ('ClaimReturnedWarningThreshold', '', '', 'Sets the number of return claims past which the librarian will be warned the patron has many return claims', 'Integer'); + } + ); + + $dbh->do( + q{ + INSERT IGNORE INTO authorised_value_categories ( category_name ) VALUES + ('RETURN_CLAIM_RESOLUTION'); + } + ); + + $dbh->do( + q{ + INSERT IGNORE INTO `authorised_values` ( category, authorised_value, lib ) + VALUES + ('RETURN_CLAIM_RESOLUTION', 'RET_BY_PATRON', 'Returned by patron'), + ('RETURN_CLAIM_RESOLUTION', 'FOUND_IN_LIB', 'Found in library'); + } + ); + + SetVersion($DBversion); + print +"Upgrade to $DBversion done (Bug 14697 - Extend and enhance 'Claims returned' lost status)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. my $update_dir = C4::Context->config('intranetdir') . '/installer/data/mysql/atomicupdate/'; -- 2.39.5