Diff taken right after Snapshot is not empty!

Certainly taking a snapshot, and then immediately running diff, should never show any differences, right? Right?

Liquibase 4.6.2. Postgres 14.1. MacOSX Monterey.

I write my snapshot file with

liquibase --defaultsFile=${PROJECT_HOME}/src/test/resources/liquibase.properties --schemas=public
–outputFile="${SNAPSHOT}" --snapshotFormat=json --log-level=DEBUG --default-catalog-name=orbit_dev snapshot

The snapshot file looks good. For instance, it starts with

  "snapshot": {
    "created": "2022-01-04T18:26:53.91",
    "database": {
      "productVersion": "14.1",
      "shortName": "postgresql",
      "majorVersion": "14",
      "minorVersion": "1",
      "user": "postgres",
      "productName": "PostgreSQL",
      "url": "jdbc:postgresql://127.0.0.1:5432/orbit_dev"
    },
    "objects": {
      "liquibase.structure.core.Catalog": [
        {
          "catalog": {
            "default": true,
            "name": "orbit_dev",
            "snapshotId": "7dfd100"
          }
        }]

Seems legit. Then, the very next thing I do is run a diff.

liquibase --defaultsFile=${PROJECT_HOME}/src/test/resources/liquibase.properties
–reference-url=“offline:postgresql=${SNAPSHOT}” --schemas=public --default-schema-name=public
–default-catalog-name=orbit_dev
–reference-username=postgres --reference-password=postgres --reference-default-catalog-name=orbit_dev
–reference-default-schema-name=public --log-level=DEBUG diff

The output looks acceptable. Nothing too alarming, although I do see

INFO [liquibase.database] Set default schema name to null

which is odd, but nevertheless, it goes on to output

Reference Database: postgres @ offline:postgresql=/Users/charleshope/Development/Orbit/snapshot.json (Default Schema: public)
Comparison Database: postgres @ jdbc:postgresql://127.0.0.1:5432/orbit_dev (Default Schema: public)
Compared Schemas: public
Product Name:
     Reference:   'Offline postgresql'
     Target: 'PostgreSQL'
Product Version:
     Reference:   NULL
     Target: '14.1'
Missing Catalog(s): NONE

Excellent, this is as expected.

But then,

Unexpected Catalog(s): 
     orbit_dev

Huh?

And then it goes on to show all my tables and so forth, as unexpected. It’s as if that snapshot is completely empty! What’s going on here?

I think your reference url should be offline:postgresql?snapshot=${SNAPSHOT}. The offline:postgresql=${SNAPSHOT} syntax isn’t right and is probably just silently ignoring the part after the = sign because there is no “key” to the key/value parameters in the url.

Does changing that help?

Nathan

1 Like