Redgate Flyway

Migrations-based approach with auto-generation of migration scripts

This approach is for teams looking to improve developer productivity with auto-generation of migration scripts. 

Onboarding tips

The tips below will focus on setting up the script auto-generation from your development database (1).

Separate instructions exist on how to set up database deployments with Flyway (3), and to maintain an object level history (2).

Flyway project setup

Ensure that a Flyway migrations project has been created with the development database, shadow database and baseline script configured.

Script auto-generation can be configured for development teams as follows:

  1. Migration scripts are generated in Flyway Desktop 
  2. Migration scripts are generated as part of a pull request
  3. Migration scripts are generated as part of an automated pipeline

For options 2 and 3, developers need not install or interact directly with the Flyway tooling, which means this model is well suited to teams that have an existing development process:

1. Migration scripts are generated in Flyway Desktop

This is suited for developers who want full control over the script generation process.

Note: the following experience is not yet implemented in Flyway Desktop and will be coming soon.

Using Flyway Desktop

  1. Visit the Generate migrations page to review changes in your development database that aren't reflected in your migration scripts
  2. Select the specific changes to be added to a new migratino script
  3. Select Generate scripts to auto-generate both the new migration script as well as the corresponding undo script.

2. Migration scripts are generated as part of a pull request

It is possible to configure script generation when using an ORM and SSDT or any database development process that leverages version control.

  1. Create a GitHub Action "on: pull_request" that:
    1. Runs flyway clean migrate on the shadow database
    2. Compares the database with the shadow database
    3. Generates a migration script from the changes
    4. Optionally generates the undo script
  2. The migration script and undo can be reviewed before the pull request is merged

If an object level history is required, an optional step to generate a schema model from the shadow database can be configured.

3. Migration scripts are generated as part of an automated pipeline

This approach is required when migration script generation can't easily be run as part of a pull request, or this isn't the desired approach. This is particularly suited to teams looking to benefit from auto-generation of migration scripts without interrupting their existing development practices.

To implement, use the same approach as described above but implement as a pipeline in your CI/CD tool. This can be manually triggered or run on a schedule.




Didn't find what you were looking for?