Reputation: 848
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?)
Upvotes: 4
Views: 5630
Reputation: 41
As well as using environment variables, you can use the flyway.conf file in the user profile folder, which only the current user can access. This is fine if you only access one database/server combination.
If you use several, then you can reference them as an extra .conf file in the user profile/user home area. For example, if, as a Windows user, you were accessing the development branch of a Pubs database project you might create a PubsDevelop.conf file in your user profile folder and specify it to Flyway by using a commandline parameter
flyway -configFiles="%userprofile%\PubsDevelop.conf" info
or if you dislike typing commands, set it up as an environemt variable
FLYWAY_CONFIG_FILES=%userprofile%\PubsDevelop.conf
That way, nobody can see your credentials or server name, and there is no risk of it leaking into the source control system by mistake!
Upvotes: 1
Reputation: 2795
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.
Upvotes: 2