0

I have an old Liquibase .xml file for adding an index to two columns. It is already in the DATABASECHANGELOG table and in Production, since years. But now i updated the H2 Database for my integration tests and they fail because of "article_id ". There is a blank space in the column name.

    <createIndex tableName="order_journal" indexName="IDX_ArticleId_Customer">
        <column name="article_id "/>
        <column name="customer_id"/>
    </createIndex>

My datasource configuration:

H2 Datasource config

I removed the blankspace and the tests worked. Of course the application doesnt start because i edited an already commited file in the changelock. What is the common way to edit an old Liquibase file or is there an approach for the H2 database?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Maks
  • 13
  • 3

1 Answers1

0

There are a couple of options, which one suites you best depends on conventions in your project.

  1. preconditions do not affect checksums: you may add precondition to the existing changeset, which prevents execution on test database, and write correct changeset for test database with opposite precondition (that is not clear how to properly distinguish test and prod databases though) - check Prevent error when dropping not existing sequences, creating existing users for example
  2. you may specify <validCheckSum> for modified changeset - seems to be exactly your case
  3. you may create another changeset for test database and mark both changesets as failOnError="false" - if changeset contains only createIndex change that seems to be safe, this scenario is also ~described in liquibase blog and Prevent error when dropping not existing sequences, creating existing users
  4. you may specify <validCheckSum>ANY</validCheckSum> - in that case you do not need to figure out what previous checksum was, however it seems not to be safe.
Andrey B. Panfilov
  • 4,324
  • 2
  • 12
  • 18