Liquibase - TagDatabase changeset updates the previous changeset with the tag as well

StackOverflow https://stackoverflow.com/questions/22927375

  •  29-06-2023
  •  | 
  •  

Pergunta

I wanted to tag the database using the following changeset in the changelog file for future rollback purposes. When I apply this changeset I have noticed in the databasechangelog the previous changeset is also updated with the tag.

The changeset in the changelog file

`<changeSet author="Major Version" id="2.0"> 
 <tagDatabase tag="version_2.0"/>
 </changeSet> `

Below is the extract from the databasechangelog table , function51 is a changeset from a previous run

===>function51|| sr || ./db-changelog.xml || 05-APR-14 12.34.46.975900000 || 15 || EXECUTED || 7:5616f4adba7690fafd882b3a607c3eca || sqlFile || **version_2.0** || 3.1.1

`===>2.0 ||    Major Version  ||   ./db-ApplyTag.xml ||    05-APR-14 12.37.24.140637000    || 16 ||    EXECUTED  ||   7:97fe9eb435a72fdfbe27647efa5be97d  ||   tagDatabase       ||  **version_2.0** ||    3.1.1`

Has anybody encountered this ? I am using Liquibase 3.1.1

Thanks.

Foi útil?

Solução

The reason is because when Liquibase runs the logic inside the changeSet is ran and then it is marked as ran in the databasechangelog table. So in the case of tagDatabase the most last ran changeSet is the previously executed one.

The rollback logic should still work correctly for you because rolling back to version_2.0 will bring you back to function51 being the last changeSet executed. Running update again will re-tag it as version_2.0 but that is fine.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top