From fb5dd4c942f7162808a97cf37f51bd41d38b0d8b Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 13 Nov 2018 16:21:22 +0000 Subject: [PATCH] Bug 15836: DBRev 18.06.00.060 Signed-off-by: Nick Clemens --- Koha.pm | 2 +- Koha/Schema/Result/ClassSource.pm | 35 +++++- Koha/Schema/Result/ClassSplitRule.pm | 100 ++++++++++++++++++ Koha/Schema/Result/SocialData.pm | 7 +- .../data/mysql/atomicupdate/bug_15836.perl | 42 -------- installer/data/mysql/updatedatabase.pl | 44 ++++++++ 6 files changed, 181 insertions(+), 49 deletions(-) create mode 100644 Koha/Schema/Result/ClassSplitRule.pm delete mode 100644 installer/data/mysql/atomicupdate/bug_15836.perl diff --git a/Koha.pm b/Koha.pm index ea91c26f86..46ba9220fb 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.06.00.059"; +$VERSION = "18.06.00.060"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/ClassSource.pm b/Koha/Schema/Result/ClassSource.pm index 6c7a4413d5..2bc8f3a638 100644 --- a/Koha/Schema/Result/ClassSource.pm +++ b/Koha/Schema/Result/ClassSource.pm @@ -49,6 +49,14 @@ __PACKAGE__->table("class_sources"); is_nullable: 0 size: 10 +=head2 class_split_rule + + data_type: 'varchar' + default_value: (empty string) + is_foreign_key: 1 + is_nullable: 0 + size: 10 + =cut __PACKAGE__->add_columns( @@ -66,6 +74,14 @@ __PACKAGE__->add_columns( is_nullable => 0, size => 10, }, + "class_split_rule", + { + data_type => "varchar", + default_value => "", + is_foreign_key => 1, + is_nullable => 0, + size => 10, + }, ); =head1 PRIMARY KEY @@ -97,9 +113,24 @@ __PACKAGE__->belongs_to( { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" }, ); +=head2 class_split_rule + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "class_split_rule", + "Koha::Schema::Result::ClassSplitRule", + { class_split_rule => "class_split_rule" }, + { is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" }, +); + -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-02-16 17:54:53 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tu9NZrk0s8VBgtc1kNpXgg +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-11-13 15:24:28 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bD/Why2Bt7rmnA9cCLIPsA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/ClassSplitRule.pm b/Koha/Schema/Result/ClassSplitRule.pm new file mode 100644 index 0000000000..9aab8b654c --- /dev/null +++ b/Koha/Schema/Result/ClassSplitRule.pm @@ -0,0 +1,100 @@ +use utf8; +package Koha::Schema::Result::ClassSplitRule; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::ClassSplitRule + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("class_split_rules"); + +=head1 ACCESSORS + +=head2 class_split_rule + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 10 + +=head2 description + + data_type: 'longtext' + is_nullable: 1 + +=head2 split_routine + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 30 + +=head2 split_regex + + data_type: 'varchar' + default_value: (empty string) + is_nullable: 0 + size: 255 + +=cut + +__PACKAGE__->add_columns( + "class_split_rule", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 10 }, + "description", + { data_type => "longtext", is_nullable => 1 }, + "split_routine", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 30 }, + "split_regex", + { data_type => "varchar", default_value => "", is_nullable => 0, size => 255 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("class_split_rule"); + +=head1 RELATIONS + +=head2 class_sources + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "class_sources", + "Koha::Schema::Result::ClassSource", + { "foreign.class_split_rule" => "self.class_split_rule" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-11-13 15:24:28 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PkAwS2zW9E20B34bFWtV4g + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/Koha/Schema/Result/SocialData.pm b/Koha/Schema/Result/SocialData.pm index b21e5088e4..b2d835b0b0 100644 --- a/Koha/Schema/Result/SocialData.pm +++ b/Koha/Schema/Result/SocialData.pm @@ -26,7 +26,6 @@ __PACKAGE__->table("social_data"); =head2 isbn data_type: 'varchar' - default_value: (empty string) is_nullable: 0 size: 30 @@ -65,7 +64,7 @@ __PACKAGE__->table("social_data"); __PACKAGE__->add_columns( "isbn", - { data_type => "varchar", default_value => "", is_nullable => 0, size => 30 }, + { data_type => "varchar", is_nullable => 0, size => 30 }, "num_critics", { data_type => "integer", is_nullable => 1 }, "num_critics_pro", @@ -93,8 +92,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("isbn"); -# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-10-14 20:56:21 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Medc/ZzPVp5Eq+adFoqQoA +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2018-11-13 15:24:28 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:l44tYFEfIKX0xXzj6AHInQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/installer/data/mysql/atomicupdate/bug_15836.perl b/installer/data/mysql/atomicupdate/bug_15836.perl deleted file mode 100644 index edfe012709..0000000000 --- a/installer/data/mysql/atomicupdate/bug_15836.perl +++ /dev/null @@ -1,42 +0,0 @@ -$DBversion = 'XXX'; -if( CheckVersion( $DBversion ) ) { - unless( TableExists( 'class_split_rules' ) ) { - $dbh->do(q| - CREATE TABLE class_split_rules ( - class_split_rule varchar(10) NOT NULL default '', - description LONGTEXT, - split_routine varchar(30) NOT NULL default '', - split_regex varchar(255) NOT NULL default '', - PRIMARY KEY (class_split_rule), - UNIQUE KEY class_split_rule_idx (class_split_rule) - ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci - |); - - $dbh->do(q| - ALTER TABLE class_sources - ADD COLUMN class_split_rule varchar(10) NOT NULL default '' - AFTER class_sort_rule - |); - $dbh->do(q| - UPDATE class_sources - SET class_split_rule = class_sort_rule - |); - - $dbh->do(q| - INSERT INTO class_split_rules(class_split_rule, description, split_routine) - VALUES - ('dewey', 'Default sorting rules for DDC', 'Dewey'), - ('lcc', 'Default sorting rules for LCC', 'LCC'), - ('generic', 'Generic call number sorting rules', 'Generic') - |); - - $dbh->do(q| - ALTER TABLE class_sources - ADD CONSTRAINT class_source_ibfk_2 FOREIGN KEY (class_split_rule) - REFERENCES class_split_rules (class_split_rule) - |); - } - - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 15836 - Add class_sort_rules.split_routine and split_regex)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 998b0035cd..2ec956e331 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -17067,6 +17067,50 @@ if( CheckVersion( $DBversion ) ) { SetVersion( $DBversion ); print "Upgrade to $DBversion done (Bug 20356 - Add EmailSMSSendDriverFromAddress system preference)\n"; } + +$DBversion = '18.06.00.060'; +if( CheckVersion( $DBversion ) ) { + unless( TableExists( 'class_split_rules' ) ) { + $dbh->do(q| + CREATE TABLE class_split_rules ( + class_split_rule varchar(10) NOT NULL default '', + description LONGTEXT, + split_routine varchar(30) NOT NULL default '', + split_regex varchar(255) NOT NULL default '', + PRIMARY KEY (class_split_rule), + UNIQUE KEY class_split_rule_idx (class_split_rule) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci + |); + + $dbh->do(q| + ALTER TABLE class_sources + ADD COLUMN class_split_rule varchar(10) NOT NULL default '' + AFTER class_sort_rule + |); + $dbh->do(q| + UPDATE class_sources + SET class_split_rule = class_sort_rule + |); + + $dbh->do(q| + INSERT INTO class_split_rules(class_split_rule, description, split_routine) + VALUES + ('dewey', 'Default sorting rules for DDC', 'Dewey'), + ('lcc', 'Default sorting rules for LCC', 'LCC'), + ('generic', 'Generic call number sorting rules', 'Generic') + |); + + $dbh->do(q| + ALTER TABLE class_sources + ADD CONSTRAINT class_source_ibfk_2 FOREIGN KEY (class_split_rule) + REFERENCES class_split_rules (class_split_rule) + |); + } + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 15836 - Add class_sort_rules.split_routine and split_regex)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5