Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0006770Openbravo ERPA. Platformpublic2009-01-02 18:192009-04-21 11:09
iperdomo 
mtaal 
highmajoralways
closedfixed 
202.6.23-gentoo-r9
pi 
pi 
Core
No
0006770: create.database fails when default role is different than System Administrator
create.database fails when the default role of Openbravo user is not System Administrator (0)
With a running Openbravo instance do:
* Change Openbravo role to Openbravo Admin and mark as default
* Mark core module as 'In Development'
* ant export.database
* ant create.database

Attached you'll find the create.database log
No tags attached.
log create.database.log (1,944) 2009-01-02 18:19
https://issues.openbravo.com/file_download.php?file_id=617&type=bug
Issue History
2009-01-02 18:19iperdomoNew Issue
2009-01-02 18:19iperdomoAssigned To => marvintm
2009-01-02 18:19iperdomosf_bug_id0 => 2482651
2009-01-02 18:19iperdomoFile Added: create.database.log
2009-01-02 18:19iperdomoRegression testing => No
2009-01-04 12:25iciordiaAssigned Tomarvintm => mtaal
2009-01-04 15:21mtaalNote Added: 0011903
2009-01-04 20:11iperdomoNote Added: 0011904
2009-01-05 10:36mtaalNote Added: 0011908
2009-01-05 10:42mtaalNote Added: 0011909
2009-01-05 10:43mtaalNote Added: 0011910
2009-01-05 10:43mtaalAssigned Tomtaal => iciordia
2009-01-05 10:43mtaalStatusnew => feedback
2009-01-05 16:05iciordiaAssigned Toiciordia => mtaal
2009-01-05 16:05iciordiaStatusfeedback => scheduled
2009-01-05 16:05iciordiaNote Added: 0011918
2009-01-05 16:05iciordiafix_in_branch => trunk
2009-01-06 14:11svnbotCheckin
2009-01-06 14:11svnbotNote Added: 0011928
2009-01-06 14:11svnbotStatusscheduled => resolved
2009-01-06 14:11svnbotResolutionopen => fixed
2009-01-06 14:11svnbotsvn_revision => 11666
2009-04-21 11:09psarobeStatusresolved => closed

Notes
(0011903)
mtaal   
2009-01-04 15:21   
Hi Ivan,
When I check the attached log it says this:
/home/iperdomo/workspaces/trunk/openbravo/src-db/database/build-create.xml:69: org.apache.ddlutils.DatabaseOperationException: Error while enabling foreign key

I do not see a direct relation between the subject of this issue and the error message in the log.
Can you give some more info?

gr. Martin
(0011904)
iperdomo   
2009-01-04 20:11   
Hi Martin,

If the AD_USER.xml the default role is different than 0, the create.database fails. Can you try to repeat the steps to reproduce the error?

I don't know direct relation between the default role and the 'enabling foreign key' error message, I just know that fails.

Best Regards,

Iván
(0011908)
mtaal   
2009-01-05 10:36   
After doing ant -debug create.database, the following stacktrace showed up:
[importdata] ALTER TABLE AD_USER
[importdata] ADD CONSTRAINT ADCLIENT_ADUSERDEFAULT FOREIGN KEY (DEFAULT_AD_CLIENT_ID) REFERENCES AD_CLIENT (AD_CLIENT_ID)
[importdata] org.postgresql.util.PSQLException: ERROR: insert or update on table "ad_user" violates foreign key constraint "adclient_aduserdefault"
[importdata] Detail: Key (default_ad_client_id)=(1000000) is not present in table "ad_client".
[importdata] at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1548)
[importdata] at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1316)
[importdata] at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:191)
[importdata] at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:452)
[importdata] at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:337)
[importdata] at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:329)
[importdata] at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:261)
[importdata] at org.apache.ddlutils.platform.PlatformImplBase.evaluateBatch(PlatformImplBase.java:341)
[importdata] at org.apache.ddlutils.platform.postgresql.PostgreSqlPlatform.enableAllFK(PostgreSqlPlatform.java:304)
(0011909)
mtaal   
2009-01-05 10:42   
The reason for the exception is the following:
- user 100 is part of sourcedata (is defined like that in the ADRD dataset
- client 1000000 is part of masterdata
- user 100 refers directly to client 1000000
- however because source data is inserted before masterdata a fk constraint violation occurs.

A similar issue arose earlier with a default language reference from the user to the language table.

A possible solution could be to export/import the 100 user as part of masterdata instead of sourcedata. But as the 100 user is explicitly part of the sourcedata there maybe unknown (for me) reasons to have the 100 user in source data.

gr. Martin
(0011910)
mtaal   
2009-01-05 10:43   
Hi Ismael,
See the notes, above can you comment and give your opinion on this issue?

Tx!

gr. Martin
(0011918)
iciordia   
2009-01-05 16:05   
Remove default columns from source.data dataset, since they can be modified by users and they are the owners of this info.

Ismael
(0011928)
svnbot   
2009-01-06 14:11   
Repository: openbravo
Revision: 11666
Author: mtaal
Date: 2009-01-06 14:11:56 +0100 (Tue, 06 Jan 2009)

fixes issue 6770, create.database fails when default role is different than System Administrator
Description, fix is to not export the columns of ad_user which refer to masterdata, this is done by changing the ADRD dataset and the AD_USER DataSetTable.

---
U trunk/src-db/database/sourcedata/AD_DATASET.xml
U trunk/src-db/database/sourcedata/AD_DATASET_COLUMN.xml
U trunk/src-db/database/sourcedata/AD_DATASET_TABLE.xml
U trunk/src-db/database/sourcedata/AD_MODULE.xml
U trunk/src-db/database/sourcedata/AD_USER.xml
---

https://dev.openbravo.com/websvn/openbravo/?rev=11666&sc=1 [^]