From 91790fdd90c8dc59b70f6defd63b088febf5b39d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Tue, 9 Oct 2018 10:41:03 +0000 Subject: [PATCH] Bug 21082: DBRev 18.06.00.037 Signed-off-by: Nick Clemens --- Koha.pm | 2 +- Koha/Schema/Result/Branch.pm | 19 ++++- Koha/Schema/Result/BranchesOverdrive.pm | 83 +++++++++++++++++++ ...-add_option_for_overdrive_patron_auth.perl | 16 ---- installer/data/mysql/updatedatabase.pl | 19 +++++ 5 files changed, 120 insertions(+), 19 deletions(-) create mode 100644 Koha/Schema/Result/BranchesOverdrive.pm delete mode 100644 installer/data/mysql/atomicupdate/bug_21082-add_option_for_overdrive_patron_auth.perl diff --git a/Koha.pm b/Koha.pm index 77153bbc7a..583cdab390 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.036"; +$VERSION = "18.06.00.037"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm index 3d349cc581..ce3527a45a 100644 --- a/Koha/Schema/Result/Branch.pm +++ b/Koha/Schema/Result/Branch.pm @@ -316,6 +316,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 branches_overdrive + +Type: might_have + +Related object: L + +=cut + +__PACKAGE__->might_have( + "branches_overdrive", + "Koha::Schema::Result::BranchesOverdrive", + { "foreign.branchcode" => "self.branchcode" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 branchtransfers_frombranches Type: has_many @@ -632,8 +647,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-05 14:29:17 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L/zUeW5lNf5oJcZ/bES7rw +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-09 10:38:33 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nKWRDScCAwZUDrRhm1kYMA # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/Koha/Schema/Result/BranchesOverdrive.pm b/Koha/Schema/Result/BranchesOverdrive.pm new file mode 100644 index 0000000000..fd14503782 --- /dev/null +++ b/Koha/Schema/Result/BranchesOverdrive.pm @@ -0,0 +1,83 @@ +use utf8; +package Koha::Schema::Result::BranchesOverdrive; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::BranchesOverdrive + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("branches_overdrive"); + +=head1 ACCESSORS + +=head2 branchcode + + data_type: 'varchar' + is_foreign_key: 1 + is_nullable: 0 + size: 10 + +=head2 authname + + data_type: 'varchar' + is_nullable: 0 + size: 255 + +=cut + +__PACKAGE__->add_columns( + "branchcode", + { data_type => "varchar", is_foreign_key => 1, is_nullable => 0, size => 10 }, + "authname", + { data_type => "varchar", is_nullable => 0, size => 255 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("branchcode"); + +=head1 RELATIONS + +=head2 branchcode + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "branchcode", + "Koha::Schema::Result::Branch", + { branchcode => "branchcode" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-10-09 10:38:33 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fEZWWtF4MRDwupI/27laDw + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/installer/data/mysql/atomicupdate/bug_21082-add_option_for_overdrive_patron_auth.perl b/installer/data/mysql/atomicupdate/bug_21082-add_option_for_overdrive_patron_auth.perl deleted file mode 100644 index 8d3742f2c0..0000000000 --- a/installer/data/mysql/atomicupdate/bug_21082-add_option_for_overdrive_patron_auth.perl +++ /dev/null @@ -1,16 +0,0 @@ -$DBversion = 'XXX'; # will be replaced by the RM -if( CheckVersion( $DBversion ) ) { - $dbh->do('DROP TABLE IF EXISTS branches_overdrive'); - $dbh->do( q| - CREATE TABLE IF NOT EXISTS branches_overdrive ( - `branchcode` VARCHAR( 10 ) NOT NULL , - `authname` VARCHAR( 255 ) NOT NULL , - PRIMARY KEY (`branchcode`) , - CONSTRAINT `branches_overdrive_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE - ) ENGINE = INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci |); - $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveAuthname', '', 'Authname for OverDrive Patron Authentication, will be used as fallback if individual branch authname not set', NULL, 'Free');"); - $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveWebsiteID','', 'WebsiteID provided by OverDrive', NULL, 'Free');"); - $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDrivePasswordRequired','', 'Does the library require passwords for OverDrive SIP authentication', NULL, 'YesNo');"); - SetVersion( $DBversion ); - print "Upgrade to $DBversion done (Bug 21082 - Add overdrive patron auth method)\n"; -} diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index e277334d3e..a49bc7d699 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -16526,6 +16526,25 @@ if( CheckVersion( $DBversion ) ) { print "Upgrade to $DBversion done (Bug 18887 - Introduce new table 'circulation_rules', use for 'max_holds' rules)\n"; } +$DBversion = '18.06.00.037'; +if( CheckVersion( $DBversion ) ) { + unless (TableExists('branches_overdrive')){ + $dbh->do( q| + CREATE TABLE IF NOT EXISTS branches_overdrive ( + `branchcode` VARCHAR( 10 ) NOT NULL , + `authname` VARCHAR( 255 ) NOT NULL , + PRIMARY KEY (`branchcode`) , + CONSTRAINT `branches_overdrive_ibfk_1` FOREIGN KEY (`branchcode`) REFERENCES `branches` (`branchcode`) ON DELETE CASCADE ON UPDATE CASCADE + ) ENGINE = INNODB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci | + ); + } + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveAuthname', '', 'Authname for OverDrive Patron Authentication, will be used as fallback if individual branch authname not set', NULL, 'Free');"); + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDriveWebsiteID','', 'WebsiteID provided by OverDrive', NULL, 'Free');"); + $dbh->do("INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('OverDrivePasswordRequired','', 'Does the library require passwords for OverDrive SIP authentication', NULL, 'YesNo');"); + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 21082 - Add overdrive patron auth method)\n"; +} + # SEE bug 13068 # if there is anything in the atomicupdate, read and execute it. -- 2.39.5