diff --git a/lib/ddl/database_manager.php b/lib/ddl/database_manager.php index ea2621fb8039f..1112bafb203a2 100644 --- a/lib/ddl/database_manager.php +++ b/lib/ddl/database_manager.php @@ -300,6 +300,8 @@ public function delete_tables_from_xmldb_file($file) { } if ($xmldb_tables = $structure->getTables()) { + // Delete in opposite order, this should help with foreign keys in the future. + $xmldb_tables = array_reverse($xmldb_tables); foreach($xmldb_tables as $table) { if ($this->table_exists($table)) { $this->drop_table($table);