@@ -1323,5 +1323,53 @@ function xmldb_local_o365_upgrade($oldversion) {
13231323 upgrade_plugin_savepoint (true , 2024100711 , 'local ' , 'o365 ' );
13241324 }
13251325
1326+ if ($ oldversion < 2025040806 ) {
1327+ // Add index to local_o365_teams_cache.objectid for better query performance.
1328+ $ table = new xmldb_table ('local_o365_teams_cache ' );
1329+ $ index = new xmldb_index ('objectid ' , XMLDB_INDEX_NOTUNIQUE , ['objectid ' ]);
1330+
1331+ // Conditionally launch add index objectid.
1332+ if (!$ dbman ->index_exists ($ table , $ index )) {
1333+ $ dbman ->add_index ($ table , $ index );
1334+ }
1335+
1336+ // Add indexes to local_o365_groups_cache for better query performance.
1337+ $ table = new xmldb_table ('local_o365_groups_cache ' );
1338+ $ index = new xmldb_index ('objectid ' , XMLDB_INDEX_NOTUNIQUE , ['objectid ' ]);
1339+
1340+ // Conditionally launch add index objectid.
1341+ if (!$ dbman ->index_exists ($ table , $ index )) {
1342+ $ dbman ->add_index ($ table , $ index );
1343+ }
1344+
1345+ $ index = new xmldb_index ('not_found_since ' , XMLDB_INDEX_NOTUNIQUE , ['not_found_since ' ]);
1346+
1347+ // Conditionally launch add index not_found_since.
1348+ if (!$ dbman ->index_exists ($ table , $ index )) {
1349+ $ dbman ->add_index ($ table , $ index );
1350+ }
1351+
1352+ // Add composite index to local_o365_objects.type and subtype for better query performance.
1353+ $ table = new xmldb_table ('local_o365_objects ' );
1354+ $ index = new xmldb_index ('type_subtype ' , XMLDB_INDEX_NOTUNIQUE , ['type ' , 'subtype ' ]);
1355+
1356+ // Conditionally launch add index type_subtype.
1357+ if (!$ dbman ->index_exists ($ table , $ index )) {
1358+ $ dbman ->add_index ($ table , $ index );
1359+ }
1360+
1361+ // Add index to local_o365_course_request.requeststatus for better query performance.
1362+ $ table = new xmldb_table ('local_o365_course_request ' );
1363+ $ index = new xmldb_index ('requeststatus ' , XMLDB_INDEX_NOTUNIQUE , ['requeststatus ' ]);
1364+
1365+ // Conditionally launch add index requeststatus.
1366+ if (!$ dbman ->index_exists ($ table , $ index )) {
1367+ $ dbman ->add_index ($ table , $ index );
1368+ }
1369+
1370+ // O365 savepoint reached.
1371+ upgrade_plugin_savepoint (true , 2025040806 , 'local ' , 'o365 ' );
1372+ }
1373+
13261374 return true ;
13271375}
0 commit comments