Liquibase changelog property substitution for Integer values

80 Views Asked by At

I'd like to use Liquibase's setChangeLogParameter to substitute in an Integer value in a changelog, but I'm not sure if this is possible. Can someone clarify how this might be done, or if this is/isn't possible?

Looking at the documentation, and official example, I see that property substitution is supported for strings (https://docs.liquibase.com/concepts/changelogs/home.html, https://github.com/liquibase/liquibase-mongodb/blob/46977b832b52873993c7ea2d3749e363d1a8fce3/src/test/resources/liquibase/ext/json/changelog.generic.json).

Specifically, in the following code example, I pass an Integer value into clusterId, but doing the substitution with double quotation marks as specified by documentation casts the Integer value into a string. I tried removing the quotation marks "${clusterId}" -> ${clusterId} but Liquibase tells me that the resulting JSON changelog cannot be parsed.

My changelog file is as follows:

{
  "databaseChangeLog": [
    {
      "changeSet": {
        "id": "1",
        "author": "admin",
        "comment": "Populate ISSUES collection",
        "changes": [
          {
            "insertMany": {
              "collectionName": "ISSUES",
              "documents": {
                "$rawJson": [
                  {
                    "CLUSTER_ID": "${clusterId}",
                    "LABEL": "defaultTag",
                    "ORDER": 1
                  },
                  {
                    "CLUSTER_ID": "${clusterId}",
                    "LABEL": "defaultIssue",
                    "ORDER": 2
                  }
                ]
              }
            }
          }
        ]
      }
    }
  ]
}
0

There are 0 best solutions below