MDL-67312 calendar: upgrade step to delete orphaned events
authorSimey Lameze <simey@moodle.com>
Thu, 21 Nov 2019 00:36:22 +0000 (08:36 +0800)
committerSara Arjona <sara@moodle.com>
Mon, 20 Jan 2020 07:08:56 +0000 (08:08 +0100)
lib/db/upgrade.php
version.php

index b87c6c1..1a7ebc4 100644 (file)
@@ -2162,5 +2162,15 @@ function xmldb_main_upgrade($oldversion) {
 
         upgrade_main_savepoint(true, 2020010900.02);
     }
 
         upgrade_main_savepoint(true, 2020010900.02);
     }
+
+    if ($oldversion < 2020011700.02) {
+        // Delete all orphaned subscription events.
+        $select = "subscriptionid IS NOT NULL
+                   AND subscriptionid NOT IN (SELECT id from {event_subscriptions})";
+        $DB->delete_records_select('event', $select);
+
+        upgrade_main_savepoint(true, 2020011700.02);
+    }
+
     return true;
 }
     return true;
 }
index fa86dab..4121111 100644 (file)
@@ -29,7 +29,7 @@
 
 defined('MOODLE_INTERNAL') || die();
 
 
 defined('MOODLE_INTERNAL') || die();
 
-$version  = 2020011700.01;              // YYYYMMDD      = weekly release date of this DEV branch.
+$version  = 2020011700.02;              // YYYYMMDD      = weekly release date of this DEV branch.
                                         //         RR    = release increments - 00 in DEV branches.
                                         //           .XX = incremental changes.
 $release  = '3.9dev (Build: 20200117)'; // Human-friendly version name
                                         //         RR    = release increments - 00 in DEV branches.
                                         //           .XX = incremental changes.
 $release  = '3.9dev (Build: 20200117)'; // Human-friendly version name