From c53f907235116b17d9c31d644c8d576e915992c6 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 5 Mar 2019 20:59:07 +0000 Subject: [PATCH] Bug 18925: DBRev 18.12.00.020 Signed-off-by: Nick Clemens --- Koha.pm | 2 +- Koha/Schema/Result/Branch.pm | 19 +--- Koha/Schema/Result/Category.pm | 34 +------ Koha/Schema/Result/DefaultBranchCircRule.pm | 18 +--- Koha/Schema/Result/DefaultCircRule.pm | 18 +--- Koha/Schema/Result/Issuingrule.pm | 18 +--- .../data/mysql/atomicupdate/bug_18925.perl | 87 ------------------ installer/data/mysql/updatedatabase.pl | 88 +++++++++++++++++++ 8 files changed, 99 insertions(+), 185 deletions(-) delete mode 100644 installer/data/mysql/atomicupdate/bug_18925.perl diff --git a/Koha.pm b/Koha.pm index a5a778c910..a30cf37baf 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 = "18.12.00.019"; +$VERSION = "18.12.00.020"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm index d8816856fa..576de646e1 100644 --- a/Koha/Schema/Result/Branch.pm +++ b/Koha/Schema/Result/Branch.pm @@ -301,21 +301,6 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 branch_borrower_circ_rules - -Type: has_many - -Related object: L - -=cut - -__PACKAGE__->has_many( - "branch_borrower_circ_rules", - "Koha::Schema::Result::BranchBorrowerCircRule", - { "foreign.branchcode" => "self.branchcode" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - =head2 branch_item_rules Type: has_many @@ -677,8 +662,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-01-03 16:10:04 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WyXH3sMlyuJIx0fd31RswA +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-05 20:42:53 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nArzlMOpUO6oVOAZUgzSRg __PACKAGE__->add_columns( '+pickup_location' => { is_boolean => 1 } diff --git a/Koha/Schema/Result/Category.pm b/Koha/Schema/Result/Category.pm index 1b61c33957..7dc10ff29c 100644 --- a/Koha/Schema/Result/Category.pm +++ b/Koha/Schema/Result/Category.pm @@ -221,21 +221,6 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 branch_borrower_circ_rules - -Type: has_many - -Related object: L - -=cut - -__PACKAGE__->has_many( - "branch_borrower_circ_rules", - "Koha::Schema::Result::BranchBorrowerCircRule", - { "foreign.categorycode" => "self.categorycode" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - =head2 categories_branches Type: has_many @@ -266,24 +251,9 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); -=head2 default_borrower_circ_rule - -Type: might_have - -Related object: L - -=cut - -__PACKAGE__->might_have( - "default_borrower_circ_rule", - "Koha::Schema::Result::DefaultBorrowerCircRule", - { "foreign.categorycode" => "self.categorycode" }, - { cascade_copy => 0, cascade_delete => 0 }, -); - -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yvHcgnSv1RXNMXJixVtt0Q +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-05 20:42:53 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:XR5anXl3qCAm/Fa/l+zYpQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/DefaultBranchCircRule.pm b/Koha/Schema/Result/DefaultBranchCircRule.pm index 776b0e4b44..e3bb1288a6 100644 --- a/Koha/Schema/Result/DefaultBranchCircRule.pm +++ b/Koha/Schema/Result/DefaultBranchCircRule.pm @@ -30,16 +30,6 @@ __PACKAGE__->table("default_branch_circ_rules"); is_nullable: 0 size: 10 -=head2 maxissueqty - - data_type: 'integer' - is_nullable: 1 - -=head2 maxonsiteissueqty - - data_type: 'integer' - is_nullable: 1 - =head2 holdallowed data_type: 'tinyint' @@ -63,10 +53,6 @@ __PACKAGE__->table("default_branch_circ_rules"); __PACKAGE__->add_columns( "branchcode", { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 }, - "maxissueqty", - { data_type => "integer", is_nullable => 1 }, - "maxonsiteissueqty", - { data_type => "integer", is_nullable => 1 }, "holdallowed", { data_type => "tinyint", is_nullable => 1 }, "hold_fulfillment_policy", @@ -110,8 +96,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-04-29 10:32:00 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wnrxD1/tp8X01YHmys02lg +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-05 20:42:53 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:SYfKl5LgCoDZVhPooF55SA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/DefaultCircRule.pm b/Koha/Schema/Result/DefaultCircRule.pm index 355f4ea385..4d34b1ced1 100644 --- a/Koha/Schema/Result/DefaultCircRule.pm +++ b/Koha/Schema/Result/DefaultCircRule.pm @@ -30,16 +30,6 @@ __PACKAGE__->table("default_circ_rules"); extra: {list => ["singleton"]} is_nullable: 0 -=head2 maxissueqty - - data_type: 'integer' - is_nullable: 1 - -=head2 maxonsiteissueqty - - data_type: 'integer' - is_nullable: 1 - =head2 holdallowed data_type: 'integer' @@ -68,10 +58,6 @@ __PACKAGE__->add_columns( extra => { list => ["singleton"] }, is_nullable => 0, }, - "maxissueqty", - { data_type => "integer", is_nullable => 1 }, - "maxonsiteissueqty", - { data_type => "integer", is_nullable => 1 }, "holdallowed", { data_type => "integer", is_nullable => 1 }, "hold_fulfillment_policy", @@ -98,8 +84,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("singleton"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-04-29 10:32:00 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fqBrj0c9h9c0eBlC0kG51w +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-05 20:42:53 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:mrebGRlc4MORi6OtUk8NyA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/Issuingrule.pm b/Koha/Schema/Result/Issuingrule.pm index 187e463c0e..6b50beb54c 100644 --- a/Koha/Schema/Result/Issuingrule.pm +++ b/Koha/Schema/Result/Issuingrule.pm @@ -97,16 +97,6 @@ __PACKAGE__->table("issuingrules"); data_type: 'integer' is_nullable: 1 -=head2 maxissueqty - - data_type: 'integer' - is_nullable: 1 - -=head2 maxonsiteissueqty - - data_type: 'integer' - is_nullable: 1 - =head2 issuelength data_type: 'integer' @@ -255,10 +245,6 @@ __PACKAGE__->add_columns( { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "accountsent", { data_type => "integer", is_nullable => 1 }, - "maxissueqty", - { data_type => "integer", is_nullable => 1 }, - "maxonsiteissueqty", - { data_type => "integer", is_nullable => 1 }, "issuelength", { data_type => "integer", is_nullable => 1 }, "lengthunit", @@ -328,8 +314,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("branchcode", "categorycode", "itemtype"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2019-01-04 03:06:35 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:slPyHZs0YvOKev3cAxdDJQ +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-03-05 20:49:11 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6bPX0BRWWQZrWFun3GP86Q # 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_18925.perl b/installer/data/mysql/atomicupdate/bug_18925.perl deleted file mode 100644 index 810901b026..0000000000 --- a/installer/data/mysql/atomicupdate/bug_18925.perl +++ /dev/null @@ -1,87 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - if ( TableExists( 'branch_borrower_circ_rules' ) ) { - if ( column_exists( 'branch_borrower_circ_rules', 'maxissueqty' ) ) { - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT categorycode, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) - FROM branch_borrower_circ_rules - "); - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT categorycode, branchcode, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) - FROM branch_borrower_circ_rules - "); - $dbh->do("DROP TABLE branch_borrower_circ_rules"); - } - } - - if ( TableExists( 'default_borrower_circ_rules' ) ) { - if ( column_exists( 'default_borrower_circ_rules', 'maxissueqty' ) ) { - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT categorycode, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) - FROM default_borrower_circ_rules - "); - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT categorycode, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) - FROM default_borrower_circ_rules - "); - $dbh->do("DROP TABLE default_borrower_circ_rules"); - } - } - - if ( column_exists( 'default_circ_rules', 'maxissueqty' ) ) { - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT NULL, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) - FROM default_circ_rules - "); - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) - FROM default_circ_rules - "); - $dbh->do("ALTER TABLE default_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); - } - - if ( column_exists( 'default_branch_circ_rules', 'maxissueqty' ) ) { - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT NULL, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) - FROM default_branch_circ_rules - "); - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) - FROM default_branch_circ_rules - "); - $dbh->do("ALTER TABLE default_branch_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); - } - - if ( column_exists( 'issuingrules', 'maxissueqty' ) ) { - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT IF(categorycode='*', NULL, categorycode), - IF(branchcode='*', NULL, branchcode), - IF(itemtype='*', NULL, itemtype), - 'maxissueqty', - COALESCE( maxissueqty, '' ) - FROM issuingrules - "); - $dbh->do(" - INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) - SELECT IF(categorycode='*', NULL, categorycode), - IF(branchcode='*', NULL, branchcode), - IF(itemtype='*', NULL, itemtype), - 'maxonsiteissueqty', - COALESCE( maxonsiteissueqty, '' ) - FROM issuingrules - "); - $dbh->do("ALTER TABLE issuingrules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); - } - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 18925 - Move maxissueqty and maxonsiteissueqty to circulation_rules)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 64c3f8922f..07f16faaa9 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -17463,6 +17463,94 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 21728 - Add 'Reserve Fee' to the account_offset_types table if missing)\n"; } +$DBversion = '18.12.00.020'; +if( CheckVersion( $DBversion ) ) { + if ( TableExists( 'branch_borrower_circ_rules' ) ) { + if ( column_exists( 'branch_borrower_circ_rules', 'maxissueqty' ) ) { + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT categorycode, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) + FROM branch_borrower_circ_rules + "); + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT categorycode, branchcode, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) + FROM branch_borrower_circ_rules + "); + $dbh->do("DROP TABLE branch_borrower_circ_rules"); + } + } + + if ( TableExists( 'default_borrower_circ_rules' ) ) { + if ( column_exists( 'default_borrower_circ_rules', 'maxissueqty' ) ) { + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT categorycode, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) + FROM default_borrower_circ_rules + "); + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT categorycode, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) + FROM default_borrower_circ_rules + "); + $dbh->do("DROP TABLE default_borrower_circ_rules"); + } + } + + if ( column_exists( 'default_circ_rules', 'maxissueqty' ) ) { + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT NULL, NULL, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) + FROM default_circ_rules + "); + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) + FROM default_circ_rules + "); + $dbh->do("ALTER TABLE default_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); + } + + if ( column_exists( 'default_branch_circ_rules', 'maxissueqty' ) ) { + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT NULL, branchcode, NULL, 'patron_maxissueqty', COALESCE( maxissueqty, '' ) + FROM default_branch_circ_rules + "); + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT NULL, NULL, NULL, 'patron_maxonsiteissueqty', COALESCE( maxonsiteissueqty, '' ) + FROM default_branch_circ_rules + "); + $dbh->do("ALTER TABLE default_branch_circ_rules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); + } + + if ( column_exists( 'issuingrules', 'maxissueqty' ) ) { + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT IF(categorycode='*', NULL, categorycode), + IF(branchcode='*', NULL, branchcode), + IF(itemtype='*', NULL, itemtype), + 'maxissueqty', + COALESCE( maxissueqty, '' ) + FROM issuingrules + "); + $dbh->do(" + INSERT INTO circulation_rules ( categorycode, branchcode, itemtype, rule_name, rule_value ) + SELECT IF(categorycode='*', NULL, categorycode), + IF(branchcode='*', NULL, branchcode), + IF(itemtype='*', NULL, itemtype), + 'maxonsiteissueqty', + COALESCE( maxonsiteissueqty, '' ) + FROM issuingrules + "); + $dbh->do("ALTER TABLE issuingrules DROP COLUMN maxissueqty, DROP COLUMN maxonsiteissueqty"); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 18925 - Move maxissueqty and maxonsiteissueqty to circulation_rules)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5