Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

execute parameterized liquibase changeset multiple times with different parameters

I have been struggling with a liquibase challenge for some time and I hope somebody here can help me:

I would like to execute a simple parameterized liquibase script multiple times on the same db schema with different parameters:

<changeSet id="1" author="me" dbms="Oracle" runOnChange="false" failOnError="true">

   <sql splitStatements="true">
      GRANT SELECT on SOME_VIEW to ${db_user};
   </sql>
</changeSet>

Now I execute liquibase one time with -Ddb_user=first_user and than with -Ddb_user=second_user. The second run fails, because liquibase calculates the checkSum after replacing the ${db_user} parameter (what makes perfect sense) and therefore the combination of id/author/filename and checkSum is already present in the DATABASECHANGELOG table.

Is there a best practice way to solve this problem?

Thanks in advance.

like image 337
woezelmann Avatar asked Nov 01 '22 05:11

woezelmann


2 Answers

There is a runOnChange as an attribute for the changeSet which will run your changeset each time it was changed. Maybe this does what you are looking for?

like image 190
Jens Avatar answered Nov 15 '22 07:11

Jens


You can always use runOnChange=true or <validCheckSum>any</validCheckSum>

There is an issue that explains this decision here: https://liquibase.jira.com/browse/CORE-2506

like image 32
George Sofianos Avatar answered Nov 15 '22 06:11

George Sofianos