Liquibase error with createPartialIndex

Hi Team,

I have an entity UserCert with 1:1 mapping to User entity, note the condition unique = true:

@JoinColumn(name = "USER_ID", unique = true)
@OneToOne(fetch = FetchType.LAZY)
private User user;

Studio creates below changeset:

<changeSet id="22" author="erep">
    <addForeignKeyConstraint baseColumnNames="USER_ID" baseTableName="EREP_USER_CERT"
                             constraintName="FK_EREP_USER_CERT_ON_USER" referencedColumnNames="ID"
                             referencedTableName="JMXSILL_USER"/>

    <createPartialIndex indexName="IDX_UC_EREP_USER_CERT_USER" tableName="EREP_USER_CERT" unique="true">
        <column name="USER_ID"/>
    </createPartialIndex>
</changeSet>

This lead to Liquibase error:

[2022-01-21 15:40:12] SEVERE [liquibase.parser] cvc-complex-type.2.4.a: Invalid content was found starting with element 'createPartialIndex'. 

I’m using Studio version 1.1.4 and PostgreSQL.

Similar issue was created in YouTrack: https://issues.jpa-buddy.com/issue/JST-1430 without a solution.

Could you please check this again?

Hi Bryan

See if this helps: Error in liquibase changelog FK Index on ManyToOne with User - #6 by getshahzad

Nope, my entity was created in Jmix using entity designer and the project is not a migration from CUBA. The index statement exists in my entity:

@Table(name = "EREP_USER_CERT", indexes = {
        @Index(name = "IDX_USERCERT_USER_ID", columnList = "USER_ID")
})

But I can’t reproduce the issue with a new project now.

With a new project, if I create the same entity relationship, it creates a unique constraint and an index as blow instead of the partialIndex:

<addUniqueConstraint columnNames="USER_ID"
                     constraintName="UC_PIT_USER_CERT_USER"
                     tableName="PIT_USER_CERT"/>

<createIndex indexName="IDX_USERCERT_USER_ID"
             tableName="PIT_USER_CERT">
    <column name="USER_ID"/>
</createIndex>

Studio team:
Can you check Jmix Studio code, under what condition, it will generate the createPartialIndex statement?

Reproduced with a new project, seems the Studio will generate createPartialIndex when the entity has traits. Could you please check:

partial-index-test.zip (82.5 KB)

Thank you for reporting the problem and providing the sample project. I reproduced the problem, and as you rightly point out, it’s related to traits, or to be precise, the Soft Delete trait. I created a new issue in youtrack https://youtrack.jmix.io/issue/JST-2506.

1 Like