Issue with Liquibase Generation When Recreating Changelog

Hello everyone,

After generating changelog for my database changes and saving it, I find myself in a scenario where I need to recreate the changelog. However, upon attempting to generate it anew, Liquibase suggests incorporating the same changes I had previously included and saved.

This repetitive behavior is puzzling because I would expect Liquibase to recognize the changes have already been applied or at least saved in the previous changelog.

There are the changesets :

<changeSet id="5"
           author="com">
    <createIndex indexName="IDX_COM_DATA_ORIGIN_UNQ"
                 tableName="COM_DATA_ORIGIN"
                 unique="true">
        <column name="CODE"/>
        <column name="SEARCH_KEY"/>
    </createIndex>
</changeSet>

I’m looking for advice on how to proceed in such a situation.

Thank you in advance

Hi

Thanks for your feedback.

In case Studio repeatedly generates some changeset you don’t want to save and apply you can ignore such changeset. Select it in the Changelog Preview dialog tree and select “Remove and Ignore” option in the toolbar above (click “minus” button). Changeset will be saved as ignored and won’t appear on the next changelog generation.

Regarding this comment: “I would expect Liquibase to recognize the changes have already been applied or at least saved in the previous changelog.”
Liquibase compares your project data model and database schema. So if previously generated createIndex change was successfully applied, then it shouldn’t be generated again. If previously generated changelog wasn’t applied, then Studio suggests to remove or execute it before generating new changelog.

Please provide more details for your case, so we can investigate why changelog was regenerated.
Idea version, Jmix version, Jmix Studio plugin version. Test project or steps to reproduce would also be very helpful.

Hello
the problem seems more complicated. We dug more into it and created a sample project.
Here is a project which reproduces the bug:
if you try to generate liquibase change logs, it will add 3 indexes that already exists in current changelogs. Save them. The database creation now fails with “object name already exists”.
indexBugSoftDelete.zip (142.0 KB)

I think that:
1- during change logs generation, liquibase should not add objects that already exist.
2- any change added through change logs generation should not fails the database creation.

Hi

Thanks for the project provided!
For sure both your points are totally valid. We’ll check what has gone wrong in this case.

Hi

I’ve checked the case you provided.
The issue caused by unique constraints defined along with unique indexes. Guess this constraints were added manually, Studio doesn’t generate unique constraints for soft deleted entities.
See e.g. 003-civility.xml:

<addUniqueConstraint columnNames="CODE, SEARCH_KEY"
                             constraintName="IDX_COM_CIVILITY_UNQ"
                             tableName="COM_CIVILITY"/>

With such unique constraints defined, Studio can’t correctly generate unique indexes for soft deleted entities.

Please check Jmix documentation Soft Deletion :: Jmix Documentation.

Hi,
I don’t think this constraint was added manually. It has been added because this entity didn’t have the soft delete traits (soft delete was added recently on some of our entities). Maybe Studio do not handle well entities that become soft delete later on. Anyway <dropUniqueConstraint /> can fix the issue.

Thanks for your answer