Merge branch 'MDL-25500-master-squashed' of git://github.com/damyon/moodle
authorSam Hemelryk <sam@moodle.com>
Wed, 29 Jan 2014 00:21:00 +0000 (13:21 +1300)
committerSam Hemelryk <sam@moodle.com>
Wed, 29 Jan 2014 00:21:00 +0000 (13:21 +1300)
1  2 
lib/db/upgrade.php

@@@ -2927,19 -2927,32 +2927,46 @@@ function xmldb_main_upgrade($oldversion
          upgrade_main_savepoint(true, 2014011701.00);
      }
  
 +    if ($oldversion < 2014012300.01) {
 +        // Remove deleted users home pages.
 +        $sql = "DELETE FROM {my_pages}
 +                WHERE EXISTS (SELECT {user}.id
 +                                  FROM {user}
 +                                  WHERE {user}.id = {my_pages}.userid
 +                                  AND {user}.deleted = 1)
 +                AND {my_pages}.private = 1";
 +        $DB->execute($sql);
 +
 +        // Reached main savepoint.
 +        upgrade_main_savepoint(true, 2014012300.01);
 +    }
 +
+     if ($oldversion < 2014012400.00) {
+         // Define table lock_db to be created.
+         $table = new xmldb_table('lock_db');
+         // Adding fields to table lock_db.
+         $table->add_field('id', XMLDB_TYPE_INTEGER, '10', null, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
+         $table->add_field('resourcekey', XMLDB_TYPE_CHAR, '255', null, XMLDB_NOTNULL, null, null);
+         $table->add_field('expires', XMLDB_TYPE_INTEGER, '10', null, null, null, null);
+         $table->add_field('owner', XMLDB_TYPE_CHAR, '36', null, null, null, null);
+         // Adding keys to table lock_db.
+         $table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
+         // Adding indexes to table lock_db.
+         $table->add_index('resourcekey_uniq', XMLDB_INDEX_UNIQUE, array('resourcekey'));
+         $table->add_index('expires_idx', XMLDB_INDEX_NOTUNIQUE, array('expires'));
+         $table->add_index('owner_idx', XMLDB_INDEX_NOTUNIQUE, array('owner'));
+         // Conditionally launch create table for lock_db.
+         if (!$dbman->table_exists($table)) {
+             $dbman->create_table($table);
+         }
+         // Main savepoint reached.
+         upgrade_main_savepoint(true, 2014012400.00);
+     }
      return true;
  }