Git Product home page Git Product logo

Comments (5)

totomz avatar totomz commented on August 29, 2024 1

@stevesaliman this is not working in 1.2.1. This is the relevant part of my build.gradle

buildscript {
  repositories {
    mavenLocal()
    mavenCentral()
  }
  dependencies {
    classpath 'org.liquibase:liquibase-gradle-plugin:1.2.1'
    classpath 'postgresql:postgresql:9.1-901.jdbc4'
  }
}

liquibase {
  activities {
    main {
      changeLogFile 'conf/liquibase/schemas/auth/update.groovy'
      url 'jdbc:postgresql://localhost:5432/test'
      changeLogParameters([seqStartValu: '100000'])
    }
  }

This results in No such property: seqStartValue for class: org.liquibase.groovy.delegate.ChangeSetDelegate

I tried with -DseqStartValue=100, and by calling System.setProperty("seqStartValue", "1000001")

With version 1.1.1 1.1.0 everything is working

from liquibase-gradle-plugin.

stevesaliman avatar stevesaliman commented on August 29, 2024 1

I have a hunch what is going on here. I can't say for sure without seeing the relevant changeSet, but I think I know what is happening. The short answer is to make sure you use single quotes around your token in the changeSet.

The longer answer is as follows:

A changeset is technically a groovy script that gets executed by the Groovy DSL parser. The problem we're trying to solve is to have a token that gets replaced by Liquibase itself. The error message you are getting suggests that the changeSet is not making it past the Groovy parser because it is not valid Groovy code - the token we want Liquibase to handle is being interpreted as a missing Groovy variable.

I just tried a test, and was able to successfully pass changelog parameters to the following changeset:

changeSet(id: 'update-data', author: 'steve') {
  def username='steve'
    update(tableName: 'steve') {
      column(name: 'description', value: '${myToken}')
    where "name='${username}'"
   }
}

There are two things to note about my changeSet.

  1. ${username} is ultimately enclosed in double quotes, so it is treated as a simple Groovy variable. The parser has no problem with it because I declared the username variable inside the script.
  2. ${myToken} is wrapped in single quotes, so Groovy treats it as a literal, and passes it through to Liquibase, which then sees it as a token. Liquibase then replaces the token with the value from my build.gradle file. In my case in have changeLogParameters([ myToken: 'myParamValue']) in my build.gradle file.

When I checked my table in the database it had "myParamValue" in the database column, just as I expected.

from liquibase-gradle-plugin.

hallatech avatar hallatech commented on August 29, 2024

I just realised what I had changed in the interim: the plugin version.
With this version it works as expected:
classpath 'net.saliman:gradle-liquibase-plugin:1.0.2' (i.e. Liquibase 3.3.2)
With the latest it doesn't work anymore:
classpath "org.liquibase:liquibase-gradle-plugin:1.2.1" (i.e. Liquibase 3.4.2)

from liquibase-gradle-plugin.

stevesaliman avatar stevesaliman commented on August 29, 2024

Changelog parameters are passed through the changelogParameters method in an activity of the liquibase block of the build.gradle file. For example:

liquibase {
  activities {
    main {
      changeLogParameters([ target: 'local'])
    }
  }
}

Would add -Dtarget=local to the arguments it passes to Liquibase. Since build.gradle is groovy code, you could use conditional logic to only pass changelog parameters if your target actually has a value.

from liquibase-gradle-plugin.

totomz avatar totomz commented on August 29, 2024

Sorry for the delay in the answer, yes you are right. Changing the quoting made it works

from liquibase-gradle-plugin.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.