Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0041149Openbravo ERPY. DBSourceManagerpublic2019-06-21 12:032019-06-26 04:55
javietxe 
AugustoMauch 
normalmajorhave not tried
closedfixed 
5
3.0PR19Q1.1 
3.0PR19Q3 
caristu
Core
No
0041149: It is not possible to delete a module if an alert rule references one of its tabs
When deleting a module that has a tab referenced by an alert rule, the following error is shown in the console (if the alert rule has produced any alerts)

Example:
[java] 33423 [main] ERROR org.apache.ddlutils.DatabaseOperationException - Error while executing SQL [java] org.postgresql.util.PSQLException: ERROR: update or delete on table "ad_alertrule" violates foreign key constraint "ad_alert_ad_alertrule" on table "ad_alert" [java] Detail: Key (ad_alertrule_id)=(035B3FEA7F244F0E8D85F25CB5FF5C5E) is still referenced from table "ad_alert".
- Install the attached module (copy it into modules, run ant ant smartbuild -Dlocal=no). It will include a module with a tab
- Execute the attached sql script. It will insert an alert rule that references the tab of the module, and an alert for the new alert rule.
- Remove the new module from the modules/ folder and compile again. The update.database process will fail because, the alert rule is removed, the alert that references it is not.
No tags attached.
causes defect 0041168 closed AugustoMauch API Change: on delete cascade added to ad_alert.ad_alertrule_id foreign key 
rar issue41149.rar (4,166) 2019-06-24 17:17
https://issues.openbravo.com/file_download.php?file_id=13050&type=bug
? insertAlertRuleAndAlert.sql (517) 2019-06-24 17:29
https://issues.openbravo.com/file_download.php?file_id=13051&type=bug
Issue History
2019-06-21 12:03javietxeNew Issue
2019-06-21 12:03javietxeAssigned To => platform
2019-06-21 12:03javietxeModules => Core
2019-06-21 12:03javietxeTriggers an Emergency Pack => No
2019-06-24 14:16javietxeResolution time => 1562882400
2019-06-24 17:17AugustoMauchFile Added: issue41149.rar
2019-06-24 17:29AugustoMauchSummaryDeleting a module that has referenced data, the update database fails => It is not possible to delete a module if an alert rule references one of its tabs
2019-06-24 17:29AugustoMauchDescription Updatedbug_revision_view_page.php?rev_id=18989#r18989
2019-06-24 17:29AugustoMauchSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=18991#r18991
2019-06-24 17:29AugustoMauchFile Added: insertAlertRuleAndAlert.sql
2019-06-24 17:33hgbotCheckin
2019-06-24 17:33hgbotNote Added: 0112984
2019-06-24 17:33hgbotStatusnew => resolved
2019-06-24 17:33hgbotResolutionopen => fixed
2019-06-24 17:33hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/f455e5388bd2f2558524d973251e84898dafb7a9 [^]
2019-06-24 17:55shuehnerAssigned Toplatform => AugustoMauch
2019-06-24 17:56shuehnerNote Added: 0112987
2019-06-25 09:16caristuReview Assigned To => caristu
2019-06-25 10:23AugustoMauchRelationship addedcauses 0041168
2019-06-25 10:23caristuNote Added: 0112999
2019-06-25 10:23caristuStatusresolved => closed
2019-06-25 10:23caristuFixed in Version => 3.0PR19Q3
2019-06-26 04:55hudsonbotCheckin
2019-06-26 04:55hudsonbotNote Added: 0113018

Notes
(0112984)
hgbot   
2019-06-24 17:33   
Repository: erp/devel/pi
Changeset: f455e5388bd2f2558524d973251e84898dafb7a9
Author: Augusto Mauch <augusto.mauch <at> openbravo.com>
Date: Mon Jun 24 17:32:34 2019 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/f455e5388bd2f2558524d973251e84898dafb7a9 [^]

Fixes issue 41149: Alerts are deleted on cascade when deleting alert rules

The update.database process was deleting entries from ad_alertrule when a tab referenced by them,
but because if a missing on delete cascade, the entries from ad_alert that referenced them were
not deleted, resulting in a data consistency exception.

---
M src-db/database/model/tables/AD_ALERT.xml
---
(0112987)
shuehner   
2019-06-24 17:56   
Possible simpler reproducer: what about just the module shipping an alertrule without the ad_tab connection. Just uninstalling that module owning the rule could maybe run into the same behavior.
(0112999)
caristu   
2019-06-25 10:23   
Reviewed + tested OK.
(0113018)
hudsonbot   
2019-06-26 04:55   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/0c724fa9726e [^]
Maturity status: Test