Placeholders variables names

Hello,

When calling CLI, I usually use placeholders variable names with dots like

-placeholders.language.description="something"

but I feel like it doesn't work anymore with the latest version (10.17), Am I right ?

I get

ERROR: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')

It works fine with versions 8 and 9.

Thanks

Tagged:

Answers

  • Hi @superdede88


    Thanks for reaching out on the Redgate forums regarding your Flyway query.

     

    The placeholders should certainly still work with dots. 

    https://documentation.red-gate.com/flyway/flyway-cli-and-api/configuration/parameters/flyway/placeholders


    The error you have provided does sometimes occur when a string is not recognized. I wonder if there is perhaps some sort of depreciation or change in variable usage that has occurred between V 8/9 & 10. 

     

    Are you able to share your Flyway command string including placeholders, scrubbing any personal data. I can help to check to see if there are any items that may have changed between V10 & previous versions. 

    Jon Kirkwood | Technical Support Engineer | Redgate Software
  • superdede88superdede88 Posts: 3 New member
    edited September 6, 2024 4:51AM
    Hi Jon,

    Thanks for the replay.

    Here are CLI call results with the latest version (only command with no placeholders succeed) and with version 9 (works fine).

    As you will see, with one or two placeholders, the error is : "Unable to parse command line params.". from three placeholders, the error becomes "java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')"

    Tests with version 10.17.2 :

    scylla:~ ngader$ cd Applications/flyway-10.17.2/

    scylla:flyway-10.17.2 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" "validate"
    Flyway Community Edition 10.17.2 by Redgate
    Flyway permit on disk is expired and cannot be refreshed automatically because there is no refresh token on disk. Please rerun auth
    No Flyway license detected for this user - using Community Edition. If you expected a Teams/Enterprise license then please add a Flyway license to your account and rerun auth. Alternatively, you can run auth -logout to remove your unlicensed permit on disk

    See release notes here: https://rd.gt/416ObMi
    Database: jdbc:postgresql://localhost:5432/lexsys (PostgreSQL 15.2)
    Successfully validated 7 migrations (execution time 00:00.036s)


    scylla:flyway-10.17.2 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" -placeholders.lexsys.super.user="admin" "validate"
    ERROR: Unable to parse command line params.

    scylla:flyway-10.17.2 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" -placeholders.lexsys.super.user="admin" -placeholders.lexsys.language="fr" "validate"
    ERROR: Unable to parse command line params.

    scylla:flyway-10.17.2 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" -placeholders.lexsys.super.user="admin" -placeholders.lexsys.language="fr" -placeholders.lexsys.language.name="fr" "validate"
    ERROR: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')


    Tests with version 9.22.3 :

    scylla:~ ngader$ cd Applications/flyway-9.22.3/

    scylla:flyway-9.22.3 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" "validate"
    WARNING: This version of Flyway is out of date. Upgrade to Flyway 10.17.2: https://rd.gt/3rXiSlV

    Flyway Community Edition 9.22.3 by Redgate
    See release notes here: https://rd.gt/416ObMi

    Database: jdbc:postgresql://localhost:5432/lexsys (PostgreSQL 15.2)
    Successfully validated 7 migrations (execution time 00:00.027s)

    scylla:flyway-9.22.3 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" -placeholders.lexsys.super.user="admin" "validate"
    WARNING: This version of Flyway is out of date. Upgrade to Flyway 10.17.2: https://rd.gt/3rXiSlV

    Flyway Community Edition 9.22.3 by Redgate
    See release notes here: https://rd.gt/416ObMi

    Database: jdbc:postgresql://localhost:5432/lexsys (PostgreSQL 15.2)
    Successfully validated 7 migrations (execution time 00:00.026s)

    scylla:flyway-9.22.3 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" -placeholders.lexsys.super.user="admin" -placeholders.lexsys.language="fr" "validate"
    WARNING: This version of Flyway is out of date. Upgrade to Flyway 10.17.2: https://rd.gt/3rXiSlV

    Flyway Community Edition 9.22.3 by Redgate
    See release notes here: https://rd.gt/416ObMi

    Database: jdbc:postgresql://localhost:5432/lexsys (PostgreSQL 15.2)
    Successfully validated 7 migrations (execution time 00:00.023s)

    scylla:flyway-9.22.3 ngader$ ./flyway -url="jdbc:postgresql://localhost:5432/lexsys?useSSL=false" -user="postgres" -password="****" -schemas="core" -locations="filesystem:$HOME/Projets/Lexsys/lexsys-back-end/lexsys-back-end-ejb/src/main/static-resources/db/migration/schema/core" -placeholders.lexsys.super.user="admin" -placeholders.lexsys.language="fr" -placeholders.lexsys.language.name="fr" "validate"
    WARNING: This version of Flyway is out of date. Upgrade to Flyway 10.17.2: https://rd.gt/3rXiSlV

    Flyway Community Edition 9.22.3 by Redgate
    See release notes here: https://rd.gt/416ObMi

    Database: jdbc:postgresql://localhost:5432/lexsys (PostgreSQL 15.2)
    Successfully validated 7 migrations (execution time 00:00.022s)


  • Thank you for providing that information.

    One thought on a change that occurred in V10 is the movement from *.conf to *.toml for the Flyway configuration file.

    This may lead to this issue as Flyway V10+ may not be able to reference your placeholders such as $HOME.

    I refer this page for a guide on the V10 release and change to *.conf files.
    https://documentation.red-gate.com/fd/flyway-v10-has-landed-222627771.html

    Can you verify if you are using a conf or toml file in your project? 

    ---

    An upgrade to the Flyway.conf file with support for "environments" 

    A new configuration format will replace the flyway.conf.  

    TOML is a similar format (key-value pairs) as the conf file although it allows us to more easily structure the data stored within it.  The reason for introducing this change is that it has allowed us to create a shared configuration file between Flyway CLI and Flyway Desktop.  An added benefit to this has been that there are many cases where you have to work with multiple DBs (for example, dev and test environments) and Flyway didn't have a convenient way to represent these.  We are now introducing the concept of environments where this represents what you need to configure to work with a particular environment.  More details regarding the environment settings can be found here.

    The easiest way to upgrade a flyway conf file to the new toml format is to open Flyway Desktop and click on the Import button within your project and let Flyway desktop do all of the work for you. 

    For a period both the .conf and .toml formats will work, but new features we only be added to the new toml configuration format.

    Jon Kirkwood | Technical Support Engineer | Redgate Software
  • Hi Jon,

    I don't use configuration files, I give all parameters on command line !

    I don't think that environment variables are a problem in version 10 because if I don't put placeholders everything works fine !

    Best regards.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file