Problems migrating to Liquibase

Hi everyone,

we have some “old” projects, where setup the liquibase configuration the wrong way. We started with C7.17 and the sql directory from the camunda-bpm-tomcat zip file.

Instead of using the sql files from the liquibase/baseline directory, we added the mysql_engine_7.17.0.sql and mysql_identity_7.17.0.sql from the “create” directory to one of our own xml files which were referenced in the db.changelog-master.xml.

   <include file="db/changelog/our_camunda-service-initial.xml" />

Here the snippet from this xml file:

    <property name="db.name" value="h2" dbms="h2"/>
    <property name="db.name" value="mysql" dbms="mysql"/>

    <changeSet author="Camunda" id="7.17.0-baseline">
        <sqlFile path="../${db.name}_engine_7.17.0.sql"
                 encoding="UTF-8"
                 relativeToChangelogFile="true"
                 splitStatements="true"
                 stripComments="true"/>
        <sqlFile path="../${db.name}_identity_7.17.0.sql"
                 encoding="UTF-8"
                 relativeToChangelogFile="true"
                 splitStatements="true"
                 stripComments="true"/>
    </changeSet>

This works fine for the first startup and all tables were created.

Now we want to update to C7.19 using the “correct” liquibase files. So we copied the content of sql/liquibase from camunda-bpm-tomcat-7.19.0.zip to our db/changelog directory and added a reference to the camunda-changelog.xml to th db.changelog-master.xml:

      <include file="db/changelog/our_camunda-service-initial.xml" />
      <include file="db/changelog/camunda-changelog.xml" />

I downloaded the liquibase client and followed the steps from here: Install the Database Schema | docs.camunda.org

So I called

liquibase changelog-sync-to-tag --tag=7.17.0 --changelog-file=src\main\resources\db\changelog\camunda-changelog.xml

The command ended successfully

Liquibase Version: 4.21.1
Liquibase Open Source 4.21.1 by Liquibase
Liquibase command 'changelog-sync-to-tag' was executed successfully.

Now I started my spring application, but liquibase failed to update the database because it is trying to create tables that already exists:

Table "ACT_GE_PROPERTY" already exists; SQL statement:
create table ACT_GE_PROPERTY (
    NAME_ varchar(64),
    VALUE_ varchar(300),
    REV_ integer,
    primary key (NAME_)
) [42101-200] [Failed SQL: (42101) create table ACT_GE_PROPERTY (
    NAME_ varchar(64),
    VALUE_ varchar(300),
    REV_ integer,
    primary key (NAME_)
)]

I thougt running the liquibase command will set a marker so it will skip the databasechanges that already were done?

I am not so familiar with liquibase, so I hope someone can help me … please :slight_smile:

Best regards,

Rainer

Here are some additional information from the DATABASECHANGELOG Table:

After the initial run with engine- and identity sql files:

ID                   Author          Tag
7.17.0-baseline      Camunda         ---

After running the liquibase changelog-sync-to-tag command:

ID                   Author          Tag
7.17.0-baseline      Camunda         ---
7.16.0-tag           Camunda         7.16.0
7.16-to-7.17         Camunda         ---
7.17.0-tag           Camunda         7.17.0

While keeping the C7.17 sql files in the db/changelog directory I enabled the camunda-changelog.xml file. When I start my spring application again, I get the error message from above.

It looks like, that liquibase didn’t recognize the tags I created with the console command and it tries to create all tables again, starting with the 7.16.0-baseline changeset (create.engine, create.history, create.identity etc)

I found the reason, why the liquibase changelog command didn’t work correctly.

I run this command from my project base directory. So the path to the changelog-file was src\main\resources\db\changelog\camunda-changelog.xml

This value was stored in the DATABASECHANGELOG table.

All other entries were just db\changelog{filename_here}

As soon as I started the liquibase command from {basedir}\src\main\resources everything works fine.

Maybe this might be a good hint for your documentation?

Best regards,

Rainer

Hi @Ironarrow! Would you be willing to create a documentation PR with your changes?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.