Bug 21065: DBRev 18.11.00.002
authorNick Clemens <nick@bywatersolutions.com>
Wed, 19 Dec 2018 16:12:52 +0000 (16:12 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 20 Dec 2018 09:34:47 +0000 (09:34 +0000)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 5ea668056a6222c88c37a8ba5ee638ad827ec284)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha.pm
Koha/Schema/Result/Accountline.pm
installer/data/mysql/atomicupdate/bug_21065.perl [deleted file]
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index ed29178..3e1c98b 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.11.00.001";
+$VERSION = "18.11.00.002";
 
 sub version {
     return $VERSION;
index 2545995..641b632 100644 (file)
@@ -37,9 +37,8 @@ __PACKAGE__->table("accountlines");
 =head2 borrowernumber
 
   data_type: 'integer'
-  default_value: 0
   is_foreign_key: 1
-  is_nullable: 0
+  is_nullable: 1
 
 =head2 accountno
 
@@ -119,12 +118,7 @@ __PACKAGE__->add_columns(
   "issue_id",
   { data_type => "integer", is_nullable => 1 },
   "borrowernumber",
-  {
-    data_type      => "integer",
-    default_value  => 0,
-    is_foreign_key => 1,
-    is_nullable    => 0,
-  },
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
   "accountno",
   { data_type => "smallint", default_value => 0, is_nullable => 0 },
   "itemnumber",
@@ -212,7 +206,12 @@ __PACKAGE__->belongs_to(
   "borrowernumber",
   "Koha::Schema::Result::Borrower",
   { borrowernumber => "borrowernumber" },
-  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+  {
+    is_deferrable => 1,
+    join_type     => "LEFT",
+    on_delete     => "SET NULL",
+    on_update     => "CASCADE",
+  },
 );
 
 =head2 itemnumber
@@ -236,8 +235,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-05-16 17:00:24
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:pygYYKxFDRLX97PyeUeLvg
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2018-12-19 16:19:16
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kvBIJshNRsm/HYJBbhm0IA
 
 sub koha_objects_class {
     'Koha::Account::Lines';
diff --git a/installer/data/mysql/atomicupdate/bug_21065.perl b/installer/data/mysql/atomicupdate/bug_21065.perl
deleted file mode 100644 (file)
index 443877b..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-$DBversion = 'XXX';  # will be replaced by the RM
-if( CheckVersion( $DBversion ) ) {
-
-    my $sth = $dbh->prepare(q|SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME='accountlines_ibfk_1'|);
-    $sth->execute;
-    if ($sth->fetchrow_hashref) {
-        $dbh->do(q|
-            ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_1;
-        |);
-        $dbh->do(q|
-            ALTER TABLE accountlines CHANGE COLUMN borrowernumber borrowernumber INT(11) DEFAULT NULL;
-        |);
-        $dbh->do(q|
-            ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_borrowers FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;
-        |);
-    }
-
-    SetVersion( $DBversion );
-    print "Upgrade to $DBversion done (Bug 21065 - Set ON DELETE SET NULL on accountlines.borrowernumber)\n";
-}
index 4ad7f3a..34e9ad9 100755 (executable)
@@ -17142,6 +17142,25 @@ if( CheckVersion( $DBversion ) ) {
     print "Upgrade to $DBversion (Bug 21961 - Fix typo in manage_didyoumean permission)\n";
 }
 
+$DBversion = '18.11.00.002';
+if( CheckVersion( $DBversion ) ) {
+    my $sth = $dbh->prepare(q|SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS WHERE CONSTRAINT_NAME='accountlines_ibfk_1'|);
+    $sth->execute;
+    if ($sth->fetchrow_hashref) {
+        $dbh->do(q|
+            ALTER TABLE accountlines DROP FOREIGN KEY accountlines_ibfk_1;
+        |);
+        $dbh->do(q|
+            ALTER TABLE accountlines CHANGE COLUMN borrowernumber borrowernumber INT(11) DEFAULT NULL;
+        |);
+        $dbh->do(q|
+            ALTER TABLE accountlines ADD CONSTRAINT accountlines_ibfk_borrowers FOREIGN KEY (borrowernumber) REFERENCES borrowers (borrowernumber) ON DELETE SET NULL ON UPDATE CASCADE;
+        |);
+    }
+    SetVersion( $DBversion );
+    print "Upgrade to $DBversion done (Bug 21065 - Set ON DELETE SET NULL on accountlines.borrowernumber)\n";
+}
+
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.