From 1d817e20c915fbf76f28ef9e7c5dc684d05a1c64 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.05.05.001 Signed-off-by: Nick Clemens (cherry picked from commit 91790fdd90c8dc59b70f6defd63b088febf5b39d) Signed-off-by: Martin Renvoize --- 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 e2698a9431..eb89015268 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.05.05.000"; +$VERSION = "18.05.05.001"; sub version { return $VERSION; diff --git a/Koha/Schema/Result/Branch.pm b/Koha/Schema/Result/Branch.pm index bb571b18de..ea010acafe 100644 --- a/Koha/Schema/Result/Branch.pm +++ b/Koha/Schema/Result/Branch.pm @@ -308,6 +308,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 @@ -609,8 +624,8 @@ __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:QOMUFz2EjvAVWCkIpNmvtg +# 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 23def3df01..c833e34d9b 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -16207,6 +16207,25 @@ if ( CheckVersion($DBversion) ) { print "Upgrade to $DBversion done (18.05.05 release)\n"; } +$DBversion = '18.05.05.001'; +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.20.1