Redgate Flyway

Callbacks

Flyway offers you the possibility to hook into its lifecycle by using Callbacks. In order to use these callbacks, name a script after the callback name (e.g. afterMigrate.sql) and put it in your configured callbacks location.

Note that callbacks are ordinarily .sql files, but can also leverage the range of file formats supported in script migrations.

Whenever the conditions are met, the callback script will be run. For example, an afterMigrate.sql script will execute after running the migrate command.

Callbacks are supported for a variety of different Flyway operations, such as migrate, undo, and clean. For a complete list of callback events, see Callback Events.

Note: Callbacks are partially supported by Native Connectors.

Common usages of callbacks

Callbacks are commonly used for

  • Recompiling procedures
  • Updating materialized views
  • Storage housekeeping (VACUUM for PostgreSQL for example)

Configuring callbacks for deployment

See Executing scripts before or after deployment via callbacks

This documentation contains proprietary information and is protected by copyright law.
Copyright © 2026 Red Gate Software Limited. All rights reserved


Didn't find what you were looking for?