skip to Main Content

To fix vulnerabilities I upgraded docker image version in my dockerfile:

old:

FROM liquibase/liquibase:4.4

new:

FROM liquibase/liquibase:4.20

But I started to get error:

addAfterColumn is not allowed on postgresql

I started to investigate this error and found out that in some changesets addAfterColumn is used.

<changeSet author="***" id="***">
    <addColumn tableName="my_table" >
      <column afterColumn="existing_column"
        name="new_column"
        type="varchar(255)" >
        <constraints nullable="true"/>
      </column>
    </addColumn>
  </changeSet>
</databaseChangeLog>

I also found this topic:

https://github.com/liquibase/liquibase/issues/3091

So I just removed afterColumn but I am not sure what side effects could I experience ? I am not familiar about reason to use afterColumn but if it is removed it could be useless but I can’t find any useful information.

Are there any other options to fix the issue ? because editing liquibase scripts will break checksums for existing databases

2

Answers


  1. As this pull request shows, previously liquibase did not warn that column ordering might not be applied, because the database does not support it. So it failed silently in older versions, but now it shows an error. Quoting the most important line:

    Breaking change: Because I fixed the validation logic, anyone who has a beforeColumn or afterColumn or position attribute on addColumn for a database that doesn’t support that will now get a validation error vs. it just being ignored.

    Login or Signup to reply.
  2. You can try to do suggestion with modifySql from here:
    https://github.com/liquibase/liquibase/issues/3094#issuecomment-1195961510

    <changeSet id="***" author="***">
        <addColumn tableName="my_table">
            <column name="new_column" type="varchar(255)"/>
        </addColumn>
        <modifySql dbms="postgresql">
            <append value=" position 4"/>
        </modifySql>
    </changeSet>
    

    It looks like in liquibase 4.13 https://github.com/liquibase/liquibase/pull/2943 they fixed something that doesn’t need to be fixed as in https://github.com/liquibase/liquibase/issues/3091 they are trying to enhance/fix their own fix. In addition to breaking backward compatibility (as @gstackoverflow wrote in the comment), it breaks the logic when the product has support for many types of databases (no error for mySQL and error for Oracle/MsSQL/PostgreSQL).

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search