Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use environment variables in flyway config file?

Tags:

java

flyway

I have Flyway config file - flyway.properties , which contains basic database connection parameters:

flyway.url=jdbc:mysql://localhost
flyway.user=test
flyway.password=test
flyway.schemas=testdb

As I know exposing parameters in such config files is a bad practice. Is it possible to use environment parameters(to create .env file to define params there and to receive them in flyway config?)

like image 722
Sam Fisher Avatar asked Oct 29 '25 14:10

Sam Fisher


1 Answers

You should be able to pass to the config file every possible property, including connections and passwords, so you don't have to store them in the config file. Something like this:

flyway -enterprise -url=jdbc:postgresql://localhost:5498/hamshackradio -user=postgres -password=dude1988 -configFiles="./conf/flyway.conf" migrate

That way you can use the environment variables from the command line much easier. This is the complete list of parameters. If you're calling the API, you can also use envVars(), but I don't have experience with that.

like image 66
Grant Fritchey Avatar answered Oct 31 '25 05:10

Grant Fritchey