Bernhard Bernhard - 7 months ago 17
SQL Question

Can applied Liquibase changesets be replaced

If I use a mysql database with utf-8 and InnoDB but liquibase causes an error because row size of a table is too large.
I have a released changeset which causes the error because it exceeds the row size.

<changeSet author="author" id="id">
<addColumn tableName="TABLE">
<column name="COLUMN" type="VARCHAR(5000)" /> <!-- Row size is too long -->
</addColumn>
</changeSet>


The solution for the problem with the row size is to change "VARCHAR(5000)" into "TEXT", but the problem is that this changeset has been executed on some systems so i cannot just change it here.

Is there any solution to tell liquibase that it should replace the changeset by another if not yet executed?

Answer

OK found a solution for this. It is possible to use validCheckSum to tell Liquibase that this changeset has been modified.

I just modified the changeset and added the tag like this.

<changeSet author="author" id="id"> 
    <validCheckSum>oldChecksum</validCheckSum>
    <validCheckSum>newChecksum</validCheckSum>  
    <addColumn tableName="TABLE">
        <column name="COLUMN" type="TEXT" />
    </addColumn>
</changeSet>

After that liquibase accepted the change set as executed so it was possible to make a new changeset which modifies the column.

<changeSet author="author" id="anotherId">
    <modifyDataType tableName="TABLE" columnName="COLUMN" newDataType="TEXT" />
</changeSet>