diff --git a/pandora_server/util/pandora_db.pl b/pandora_server/util/pandora_db.pl index 6f888c6e1e..35ec7e9f02 100644 --- a/pandora_server/util/pandora_db.pl +++ b/pandora_server/util/pandora_db.pl @@ -292,12 +292,22 @@ sub pandora_purgedb ($$) { # Delete pending modules log_message ('PURGE', "Deleting pending delete modules (data table).", ''); + my @deleted_modules = get_db_rows ($dbh, 'SELECT id_agente_modulo FROM tagente_modulo WHERE delete_pending = 1'); + my @all_modules = get_db_rows ($dbh, 'SELECT id_agente_modulo, parent_module_id FROM tagente_modulo'); foreach my $module (@deleted_modules) { my $buffer = 1000; my $id_module = $module->{'id_agente_modulo'}; - + + foreach my $m (@all_modules) { + my $id_parent = $m->{'parent_module_id'}; + my $id_module_fetched = $m->{'id_agente_modulo'}; + if ($id_parent == $id_module) { + db_do ($dbh, 'UPDATE tagente_modulo SET parent_module_id=0 WHERE id_agente_modulo=?', $id_module_fetched); + } + } + log_message ('', "."); while(1) {