2

We are new to liquibase and trying to create schema's dynamically like this

<property name="schemaName" value="temp2"/>
<changeSet author="abcd" id="1">
    <sql dbms="postgresql" endDelimiter=";">
        CREATE SCHEMA $(schemaName)
    </sql>
</changeSet>

But we are getting this exception when we try to execute

    Unexpected error running Liquibase: ERROR: syntax error at or near "$"
  Position: 15 [Failed SQL: (0) CREATE SCHEMA $(schemaName)]
liquibase.exception.MigrationFailedException: Migration failed for change set src/main/db/changelog2.xml::1::aditya:
     Reason: liquibase.exception.DatabaseException: ERROR: syntax error at or near "$"
  Position: 15 [Failed SQL: (0) CREATE SCHEMA $(schemaName)]
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:646)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:53)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:83)
        at liquibase.Liquibase.update(Liquibase.java:202)
        at liquibase.Liquibase.update(Liquibase.java:179)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1223)
        at liquibase.integration.commandline.Main.run(Main.java:209)
        at liquibase.integration.commandline.Main.main(Main.java:132)

It would be of great help if the community could please point us right direction

user2359997
  • 561
  • 1
  • 16
  • 40
  • 1
    Please don't put images in your question, if they clearly be more useable as text. No one can search your image or copy something out of it. – cfrick Nov 26 '19 at 17:57

1 Answers1

2

You can use replaceable parameters in your changelog - these are called changelog parameters

The syntax is to use ${parameterName} in the changelog (note curly braces rather than parentheses).

SteveDonie
  • 8,700
  • 3
  • 43
  • 43
  • Did you mean [property substitution](https://docs.liquibase.com/concepts/changelogs/property-substitution.html)? – Mára Toner Mar 23 '23 at 20:37
  • Property substitution and changelog parameters are similar - please check the manual for each to see which one better suits your use case. – SteveDonie Mar 24 '23 at 21:34