Hi
I have an application component where I have created some Entities e.g Country, Currency etc.
It works fine at the component level. However, when I am running database script update in the main application where I have used this application component. database update is failed with the following exception. It seems the Studio is trying to create the same Entity again. Thanks for your help.
[23:20:41.773] Task 'updateDb' failed
org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "sys_db_changelog_pkey"
Detail: Key (script_name)=(50-inteaccmd/update/postgres/18/180206-0-dropCustomerShipper.sql) already exists.
[23:22:26.887] Unapplied scripts deleted: 180206-0-dropCarrierVendor01_DropScript.sql 180206-0-dropShipperCustomer01_DropScript.sql 180206-0-dropCarrierVendor01.sql 180206-0-dropShipperCustomer01.sql 180206-2-updateMdCustomer02.sql 180206-2-updateMdCustomer03.sql
[23:22:26.890] Updating database jdbc:postgresql://localhost/inteacclcs
[23:22:26.890] Executing Gradle task: updateDb
:myApp-core:assembleDbScripts
:myApp-core:updateDb
No init scripts from 50-inteaccmd have been executed, running init scripts
Executing SQL script: /Users/mak/Projects/inteacclcs/modules/core/build/db/50-inteaccmd/init/postgres/10.create-db.sql
Failed to execute: -- begin MD_COUNTRY
create table MD_COUNTRY (
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),
--
CCODE varchar(4),
NAME varchar(255),
CONTINENT_ID uuid,
--
primary key (ID)
) because: ERROR: relation "md_country" 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-inteaccmd/update/postgres/18/180206-0-dropCustomerShipper.sql) already exists.
:InteaccLogisticsCollaboration-core:updateDb FAILED
FAILURE: Build failed with an exception.
Hi Yuriy
Sorry about that but I used </> this icon in editor and landed with that format!!
Anyways, I noticed that this issue is coming from a new application component that I have created in version 6.8. This app component is compiled in studio with success message but I noticed that there is error reported in app.log file. I have attached the app.log file from the app component application. Thanks for your help. app.txt (22.9 KB)
Hi,
We have reproduced the problem. See the YouTrack issue.
New Studio generates DB-scripts for application components if they are missed.
It seems the following sequence took place:
DB scripts for PostgreSQL were not generated in the 'inteaccmd" project so they were generated in the main application.
Then you worked with PostgreSQL in “inteaccmd” and the DB scripts were generated.
This yielded updateDB failure in the main application.
Right? The reason is that the new init-scripts are launched but the corresponding tables have been already created in the main application.
You can remove the generated for component scripts from the main application. Their names are started with “01.” and “02.”
Hi Rostislav
Can you also have a look at the app.log file attached. This is from the component application log. It seems this is another problem. I can’t run the component app due this issue. component app.txt (31.8 KB)
Hi Rostislav
That behaviour of the tool is not normal as I created those entities and never removed the field delete_ts . I believe you will be find the root cause and have them fixed.