Differences Between: [Versions 310 and 403] [Versions 311 and 403] [Versions 39 and 403] [Versions 400 and 403] [Versions 401 and 403] [Versions 402 and 403]
1 <?php 2 // This file keeps track of upgrades to 3 // the data module 4 // 5 // Sometimes, changes between versions involve 6 // alterations to database structures and other 7 // major things that may break installations. 8 // 9 // The upgrade function in this file will attempt 10 // to perform all the necessary actions to upgrade 11 // your older installation to the current version. 12 // 13 // If there's something it cannot do itself, it 14 // will tell you what you need to do. 15 // 16 // The commands in here will all be database-neutral, 17 // using the methods of database_manager class 18 // 19 // Please do not forget to use upgrade_set_timeout() 20 // before any action that may take longer time to finish. 21 22 defined('MOODLE_INTERNAL') || die(); 23 24 function xmldb_data_upgrade($oldversion) { 25 global $DB; 26 27 $dbman = $DB->get_manager(); // Loads ddl manager and xmldb classes. 28 29 // Automatically generated Moodle v3.9.0 release upgrade line. 30 // Put any upgrade step following this. 31 32 // Automatically generated Moodle v4.0.0 release upgrade line. 33 // Put any upgrade step following this. 34 if ($oldversion < 2022081600) { 35 // Define key userid (foreign) to be added to data_records. 36 $table = new xmldb_table('data_records'); 37 $key = new xmldb_key('userid', XMLDB_KEY_FOREIGN, ['userid'], 'user', ['id']); 38 // Launch add key userid. 39 $dbman->add_key($table, $key); 40 41 // Data savepoint reached. 42 upgrade_mod_savepoint(true, 2022081600, 'data'); 43 } 44 45 // Automatically generated Moodle v4.1.0 release upgrade line. 46 // Put any upgrade step following this. 47 48 // Automatically generated Moodle v4.2.0 release upgrade line. 49 // Put any upgrade step following this. 50 51 if ($oldversion < 2023061300) { 52 // Clean orphan data_records. 53 $sql = "SELECT d.id FROM {data} d 54 LEFT JOIN {data_fields} f ON d.id = f.dataid 55 WHERE f.id IS NULL"; 56 $emptydatas = $DB->get_records_sql($sql); 57 if (!empty($emptydatas)) { 58 $dataids = array_keys($emptydatas); 59 list($datainsql, $dataparams) = $DB->get_in_or_equal($dataids, SQL_PARAMS_NAMED, 'data'); 60 $DB->delete_records_select('data_records', "dataid $datainsql", $dataparams); 61 } 62 63 // Data savepoint reached. 64 upgrade_mod_savepoint(true, 2023061300, 'data'); 65 } 66 67 // Automatically generated Moodle v4.3.0 release upgrade line. 68 // Put any upgrade step following this. 69 70 return true; 71 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body