liquibase / liquibase-gradle-plugin

A Gradle plugin for Liquibase
Other
199 stars 59 forks source link

Additional command parameters #64

Closed erikhugintech closed 4 years ago

erikhugintech commented 4 years ago

"snapshotFormat" should be a command parameter - it's currently not possible to create a json snapshot using the gradle plugin.

stevesaliman commented 4 years ago

You should be able to add snapshotFormat "json" to an "activity" block.

For example, the following liquibase block in my build.gradle worked for me when I ran "gradle snapshot" using the current version of the Liquibase plugin:

liquibase {
  activities {
    main {
      logLevel "debug"
      changeLogFile "${dbDir}/my_changelog.groovy"
      url project.ext.jdbcUrl
      username project.ext.jdbcUsername
      password project.ext.jdbcPassword
      snapshotFormat "json"
      outputFile "mysnapshot.json"
    }
  }
}

You can always create a second activity and use the runList property to run it if you need a separate activity just for snapshots. The README file has some good examples of multiple activity blocks.

erikhugintech commented 4 years ago

The plugin doesn't place snapshotFormat after the snapshot command, so liquibase ignores the parameter. There's a hardcoded list of parameter names that are considered to be command parameters, "snapshotFormat" should be added to this list.

stevesaliman commented 4 years ago

Ah, I see what you mean now - I was fooled by the presence of the mysnapshot.json file.

It looks like they've changed how argument parsing works since the last time I looked at it, and there may be other arguments that have this issue now. I'll look into it.

stevesaliman commented 4 years ago

Version 2.0.2 of the plugin has been released and should start showing up in the usual locations shortly.

FYI, it looks like Liquibase itself changed something in version 3.8.1 that broke JSON snapshots. In version 3.8.0 they work fine, but version 3.8.1 complains that there is nothing that can serialize JSON. My guess is that they no longer automatically include the JSON serializers, and that you'd only need to add one to the liquibaseRuntime dependencies.