SQL Server How do I use the Flyway command-line client and flyway.conf to migrate multiple databases?

huwehgph  于 12个月前  发布在  其他
关注(0)|答案(3)|浏览(97)

I started using flyway and its easy , but i only tried it with one Database. setting flyway.url to that database Using flyway migrate from command line to execute all the scripts. This is the current Setting.

flyway.driver=net.sourceforge.jtds.jdbc.Driver

Jdbc url to use to connect to the database

flyway.url=jdbc:jtds:sqlserver://'databaseName'

User to use to connect to the database (default: <>)

flyway.user=user

Password to use to connect to the database (default: <>)

flyway.password=user

but i am having problem with multiple databases and scripts for each DB, how can i set flyway to migrate data to all the databases ? run separate schema for each ? can i add multiple databases info to the config file? what should i set my flyway.url to in the properties file

7z5jn7bk

7z5jn7bk1#

I am assuming you are using the command-line client. It has a -configFile option that lets you choose which config file to use. Simply use one config file per DB and you should be OK.

oyjwcjzk

oyjwcjzk2#

I am assuming you are using the command-line client. It has a -configFile option that lets you choose which config file to use. Simply use one config file per database and you should be ok.

For example, if you have Flyway installed in a folder called c:/Flyway:

  • Copy your conf/flyway.conf file to a file called conf/prod.conf.
  • Open it and update the username, password, and url properties, e.g:

flyway.url=jdbc:postgresql://dbinstance.eu.rds.amazonaws.com:5432/myapp

  • Then run in a command prompt (shell):

flyway -configFile=c:/flyway/conf/prod.conf migrate

ohfgkhjo

ohfgkhjo3#

There is actually useful documentation on the topic: https://documentation.red-gate.com/fd/configuration-files-224003079.html

And the configuration property of the CLI is now called -configFiles and allows specifying multiple entries.

E.g. create a file per database with connection properties like

flyway-local.conf:

flyway.url=jdbc:postgresql://localhost:5432/foo
flyway.username=bar
flyway.password=baz

And reference it with ./flyway -configFiles=flyway-local.conf migrate

相关问题