How can we help you today? How can we help you today?

What is the recommended way to set up Flyway on an Octopus Deploy worker?

I am unable to find documentation on setting up Flyway on an Octopus Deploy worker. We are unable to use an execution container at this time.

We have licenses for Flyway enterprise. 

What flyway product should be downloaded? Where should it be downloaded? What else should be done?
john123456
0

Comments

3 comments

  • Jon_Kirkwood

    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:
    • 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
    0
  • john123456
    Thanks @Jon_Kirkwood

    Another related question. How would I register that Octopus Deploy worker as a licensed user?
    john123456
    0
  • Jon_Kirkwood
    Within Flyway, you can use the -licenseKey param to pass in a valid Flyway CLI license key (it should be 516 characters starting with FL)
    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.
    Jon_Kirkwood
    0

Add comment

Please sign in to leave a comment.