Redgate Flyway

Tutorial - Baseline downstream environment

To baseline your downstream environments in Flyway Desktop, add a target database on the Migrations tab.

 

If your project already has a Development Database specified, it will appear in the list.  You do not need to baseline your Development Database.

  1. For baselining downstream environments (Test > QA > Staging > Prod), click Add target database... and specify the connection details for your downstream environment:

  2. Make sure your downstream environment is selected with the green tick and then click Close.|
  3. Choose the Baseline option from the dropdown.
  4. To be explicit about what baseline version to apply (or to apply a baseline script generated before Flyway Desktop version 6.0.4), add the BaselineVersion parameter and copy and paste the Baseline script's version number or the version number that you want to apply to that environment.  
    If your baseline script was created on Flyway Desktop version 6.0.4 or later, the Baseline Version configuration parameter will be set by default and used as the version to be applied to that environment.
  5. Optional - Click View Dry Run to see what the baselining will do to your downstream environment.  
  6. Click Run Baseline.  This will add a flyway_schema_history table to your target database to track which versioned migrations have already been applied to that target database.  This will also add an entry into the table with the information about the baseline and when it was set.  The next time you migrate to this target database, only versioned migration scripts that are higher than the baselineVersion will be applied.  


Pre-requisites

  • Ensure that Flyway is installed and available on your path
  • Ensure that Flyway is authenticated to use enterprise features
  • Ensure that any secrets necessary for database connection auth are avaialbale

Commands to run

If you need to baseline to a specific migration version, append -baselineVersion=<version number> to the command in the next step, though note that it is usually better to configure this in your toml project file, so it will apply to all environments.

If your target environment, here with id production, is defined in your toml configuration run the following

flyway baseline -environment=production 

If you instead want to pass in the target connection information inline, instead run the following

flyway baseline "-url=<JDBC URL>"

Related command reference

Related configuration reference



Didn't find what you were looking for?