Bug 21082: DBRev 18.06.00.037
authorNick Clemens <nick@bywatersolutions.com>
Tue, 9 Oct 2018 10:41:03 +0000 (10:41 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Tue, 9 Oct 2018 11:04:23 +0000 (11:04 +0000)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Koha.pm
Koha/Schema/Result/Branch.pm
Koha/Schema/Result/BranchesOverdrive.pm [new file with mode: 0644]
installer/data/mysql/atomicupdate/bug_21082-add_option_for_overdrive_patron_auth.perl [deleted file]
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index 77153bb..583cdab 100644 (file)
--- 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;
index 3d349cc..ce3527a 100644 (file)
@@ -316,6 +316,21 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+=head2 branches_overdrive
+
+Type: might_have
+
+Related object: L<Koha::Schema::Result::BranchesOverdrive>
+
+=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 (file)
index 0000000..fd14503
--- /dev/null
@@ -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<branches_overdrive>
+
+=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</branchcode>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("branchcode");
+
+=head1 RELATIONS
+
+=head2 branchcode
+
+Type: belongs_to
+
+Related object: L<Koha::Schema::Result::Branch>
+
+=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 (file)
index 8d3742f..0000000
+++ /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";
-}
index e277334..a49bc7d 100755 (executable)
@@ -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.