Bug 14205: DBRev 3.21.00.22
authorTomas Cohen Arazi <tomascohen@unc.edu.ar>
Wed, 2 Sep 2015 12:45:35 +0000 (09:45 -0300)
committerTomas Cohen Arazi <tomascohen@unc.edu.ar>
Wed, 2 Sep 2015 12:56:43 +0000 (09:56 -0300)
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
Koha.pm
installer/data/mysql/atomicupdate/bug_14205-add_fk_course_reserves_ci_id.sql [deleted file]
installer/data/mysql/updatedatabase.pl

diff --git a/Koha.pm b/Koha.pm
index d507d1f..ee96adf 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 = "3.21.00.021";
+$VERSION = "3.21.00.022";
 
 sub version {
     return $VERSION;
diff --git a/installer/data/mysql/atomicupdate/bug_14205-add_fk_course_reserves_ci_id.sql b/installer/data/mysql/atomicupdate/bug_14205-add_fk_course_reserves_ci_id.sql
deleted file mode 100644 (file)
index 1a68545..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-DELETE cr.* FROM course_reserves AS cr LEFT JOIN course_items USING(ci_id) WHERE course_items.ci_id IS NULL;
-ALTER TABLE course_reserves add CONSTRAINT course_reserves_ibfk_2 FOREIGN KEY (ci_id) REFERENCES course_items (ci_id) ON DELETE CASCADE ON UPDATE CASCADE;
index 6e99abb..7f340a6 100755 (executable)
@@ -10796,6 +10796,24 @@ if ( CheckVersion($DBversion) ) {
     SetVersion($DBversion);
 }
 
+$DBversion = "3.21.00.022";
+if ( CheckVersion($DBversion) ) {
+    $dbh->do(q{
+        DELETE cr.*
+        FROM course_reserves AS cr
+        LEFT JOIN course_items USING(ci_id)
+        WHERE course_items.ci_id IS NULL
+    });
+    $dbh->do(q{
+        ALTER IGNORE TABLE course_reserves
+            add CONSTRAINT course_reserves_ibfk_2
+                FOREIGN KEY (ci_id) REFERENCES course_items (ci_id)
+                ON DELETE CASCADE ON UPDATE CASCADE
+    });
+    print "Upgrade to $DBversion done (Bug 14205: Deleting an Item/Record does not remove link to course reserve)\n";
+    SetVersion($DBversion);
+}
+
 # DEVELOPER PROCESS, search for anything to execute in the db_update directory
 # SEE bug 13068
 # if there is anything in the atomicupdate, read and execute it.