Exception while updating database from the project using application component

I have 3 components and some are working and some not.

  1. Accounting 2) Inventorycontrol 3) AccountsReceivable

While Accounting is component of Inventorycontrol, it’s working well and i am able to use the Entity created in Accounting into Inventorycontrol.

However, when I am using those three components into another project salesorder, database update is giving exception for the duplicate entity in one of the component as below. I took the following steps in application component:

  1. add component descriptor
  2. Run application server
  3. Install app component

I also tried like this sequence:
1.Clean, assembly
2. recreate component descriptor
3. Install app component


Total time: 2.395 secs
[15:43:19.671] Stopping Gradle daemon
[15:43:24.272] Stopping daemon(s).
Gradle daemon stopped.
[15:43:24.273] Running 'install' task
:inventorycontrol-core:assembleDbScripts UP-TO-DATE
:inventorycontrol-core:dbScriptsArchive UP-TO-DATE

Used all 3 app component in another project. The entities are available in this project but couldn’t update the database for the entities i created in this main project, got the following exception: The you will see the message below appears to be related a to an entity that is created in in component project and used (Association) in the main application.

[15:54:58.906] Updating database jdbc:postgresql://localhost/myms
Script 50-myemsic/init/postgres/10.create-db.sql has not been applied, running init scripts
Executing SQL script: D:\Studio Projects\ems\myemsso\modules\core\build\db\50-myemsic\init\postgres\10.create-db.sql
Failed to execute: -- begin MYEMSIC_MATERIAL
create table MYEMSIC_MATERIAL (
    ID uuid,
    VERSION integer not null,
    CREATE_TS timestamp,
    CREATED_BY varchar(50),
    UPDATE_TS timestamp,
    UPDATED_BY varchar(50),
    DELETE_TS timestamp,
    DELETED_BY varchar(50),
    DOC_NUMBER bigint,
    NAME varchar(255),
    SPECIFICATION varchar(255),
    MATERIAL_TYPE varchar(50),
    primary key (ID)
) because: ERROR: relation "myemsic_material" already exists
Failed to execute: insert into SYS_DB_CHANGELOG (SCRIPT_NAME, IS_INIT) values (?, ?) because: ERROR: duplicate key value violates unique constraint "sys_db_changelog_pkey"
  Detail: Key (script_name)=(50-myemsic/update/postgres/16/161014-1-createMaterial.sql) already exists.

:myemsso-core:updateDb FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':myemsso-core:updateDb'.
> org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "sys_db_changelog_pkey"
  Detail: Key (script_name)=(50-myemsic/update/postgres/16/161014-1-createMaterial.sql) already exists.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.


Total time: 10.994 secs
[15:55:11.164] Task 'updateDb' failed
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "sys_db_changelog_pkey"
  Detail: Key (script_name)=(50-myemsic/update/postgres/16/161014-1-createMaterial.sql) already exists.

Note that the Entity Material is existing in Inventorycontrol component and not created in the main app. What could be the reason causing this error and the fix?

Hi, Mortoza.

The described problem might occur in the following scenario:

  1. The “InventoryControl” project was installed to Maven.
  2. It was included to “AccountsReceivable” as a component.
  3. After that, “Accounting” was included to “InventoryControl”
  4. The “InventoryControl” project was reassembled and reinstalled to Maven, but the “AccountsReceivable” - not.

Now the installed to maven project stores all the DB-scripts from its components. And as a result of the steps above, DB-scripts from “InventoryControl” were added to the “SalesOrder” project twice. So the described error occurred during the scripts execution.

After the project is built you can see the assembled DB-scripts in the ${project_home}\modules\core\build\db directory. Look, are there two ??-myemsic child folders?

To prevent such issues, rebuild and reinstall to Maven all the projects which have dependencies on the modified one.

Anyway, we are going to change the behavior and store only scripts for the current project in artifacts. The link to the corresponding YouTrack issue, is on the right.

Thank you for reporting the problem.

Thank you Rostislav for your help. When do you think going to release this in a fix?

Hi Rostislav
I have checked all the project and found inventory control component was listed twice and have deleted one of them

However, After compiling both prject and tried to run, it’s failing table update/create .

Any further clue?


let me know if you need any further info to help.


Have you reinstalled your projects to Maven?

On your question: If you open the linked YouTrack Issue (link is on the right), you will see the “Fix versions” field: now it is scheduled on 6.3.5.

:ticket: See the following issue in our bug tracker: