What is the recommended way to set up Flyway on an Octopus Deploy worker?
We have licenses for Flyway enterprise.
What flyway product should be downloaded? Where should it be downloaded? What else should be done?
Best Answer
-
Jon_Kirkwood Posts: 441 Gold 1
Hi @john123456
Thank you for reaching out on the Redgate forums regarding your Flyway & Octopus Deploy inquiry.
I can certainly see that Octopus have published guides for running Flyway with Execution Containers
https://octopus.com/blog/flyway-deployments-with-execution-containers
However, there doesn't appear to be much published for running it on a worker.
I don't have full knowledge of what the Octopus Deploy workers can function as, but this information below is a high level outline on how we would anticipate it to be setup
- Which Flyway Product to Download: For Flyway Enterprise, you'll want to download the Flyway Command-line Tool. The Enterprise version includes additional features over the Community version, like undo migrations and more.
- Installation Steps:
- Download the Flyway Command-line Tool: https://download.red-gate.com/maven/release/org/flywaydb/enterprise/flyway-commandline/
- Extract to Your Worker: Once downloaded, extract the Flyway package to a suitable location on your Octopus Deploy worker. Consider a path like C:\Tools\Flyway or /opt/flyway on Linux.
- Configuring Flyway:
- Configuration File: Flyway can be configured via a flyway.toml file (link). Place your database connection settings, locations of your migration scripts, and any other Flyway configurations here.
- Environment Variables: Alternatively, you can configure Flyway using environment variables, which might be easier to manage via Octopus Deploy variables for different environments.
- Octopus Deploy Project Setup:
- Create a new project for your database migrations or integrate into an existing project.
- Add a deployment step that runs a script. This script will execute the Flyway command-line tool using PowerShell or Bash, depending on your worker's OS.
- Script Example: Here’s a PowerShell snippet for running Flyway:
$flywayPath = "C:\Tools\Flyway\flyway.cmd" $dbUrl = "yourDatabaseUrl" $dbUser = "yourDatabaseUser" $dbPassword = "yourDatabasePassword" & $flywayPath migrate -url=$dbUrl -user=$dbUser -password=$dbPassword
Adjust the paths and variables to suit your setup. Make sure to use Octopus variables for sensitive information like passwords.
- Testing: Before running this in production, test your setup in a development environment to ensure everything works as expected.
- Version Control: Keep your Flyway configurations and SQL migration scripts in version control to manage changes over time efficiently.
Some guides from our documentation for deployment into CI/CD pipelines can be found here:
https://documentation.red-gate.com/fd/deploying-database-changes-via-a-pipeline-138347136.html
https://documentation.red-gate.com/fd/octopus-deploy-208896621.html
Hope this assists with your inquiry
Jon Kirkwood | Technical Support Engineer | Redgate Software
Answers
Another related question. How would I register that Octopus Deploy worker as a licensed user?
https://documentation.red-gate.com/flyway/flyway-cli-and-api/configuration/parameters/flyway/license-key
This can be part of the command run within the worker, or as part of the configuration stored in the toml file or project settings.
If a valid license key is not found, Flyway will run at a Community level. This may reduce available functionality if you are utilizing Teams or Enterprise functionality in your pipeline.