postgresqlliquibaseliquibase-sql

Passing parameters in sqlfile tag in liquibase 4.0


I am making a simple CI/CD pipeline in which there are some sql files that i need to run on aws RDS using liquibase. Here schema name can be different and will depend on the branch from which the code is pulled. Sample sql in createSchema.sql file :

create schema if not exist '${schemaName}'

in my changelog.xml file i am doing something like this :

<changeSet author="liquibase-docs" id="sqlFile-example">
     <sqlFile 
        path="createSchema.sql"
        splitStatements="true"
        stripComments="true">
<property name="schemaName" value="test_order"/>
</sqlFile>
</changeSet>

But this thing is not working. I am also not able to find any solid info regarding to pass params in an external file in liquibase. Please let me know what do i need to do to fix it.


Solution

  • I use Liquibase CLI, and you can pass parameters (key=value) in from the command line:

    liquibase.bat update -Dengine=myisam

    More info: https://docs.liquibase.com/tools-integrations/cli/home.html