CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-flywaydb--flyway-core

Database migration tool that enables versioned database schema evolution with simple SQL scripts and Java migrations

Pending
Overview
Eval results
Files

callbacks.mddocs/

Callback System

Extensible lifecycle hooks enabling custom logic execution at any point during migration operations, providing comprehensive integration points for auditing, logging, and custom behavior.

Capabilities

Callback Interface

/**
 * Callback for receiving notifications before and after each migration.
 */
public interface Callback {
    /** Whether this callback supports the given event and context */
    boolean supports(Event event, Context context);
    
    /** Handle the callback event */
    void handle(Event event, Context context);
}

/**
 * Base implementation of Callback with convenient defaults
 */
public abstract class BaseCallback implements Callback {
    public boolean supports(Event event, Context context) {
        return true; // Support all events by default
    }
    
    public abstract void handle(Event event, Context context);
}

Callback Events

/**
 * Enumeration of all callback events
 */
public enum Event {
    // Migration events
    BEFORE_MIGRATE, AFTER_MIGRATE, BEFORE_EACH_MIGRATE, AFTER_EACH_MIGRATE,
    BEFORE_EACH_MIGRATE_STATEMENT, AFTER_EACH_MIGRATE_STATEMENT,
    
    // Validation events  
    BEFORE_VALIDATE, AFTER_VALIDATE,
    
    // Clean events
    BEFORE_CLEAN, AFTER_CLEAN,
    
    // Baseline events
    BEFORE_BASELINE, AFTER_BASELINE,
    
    // Repair events
    BEFORE_REPAIR, AFTER_REPAIR,
    
    // Info events
    BEFORE_INFO, AFTER_INFO,
    
    // Undo events
    BEFORE_UNDO, AFTER_UNDO, BEFORE_EACH_UNDO, AFTER_EACH_UNDO
}

Callback Context

/**
 * The context relevant to a callback.
 */
public interface Context {
    /** Get the configuration currently in use */
    Configuration getConfiguration();
    
    /** Get the JDBC connection to use to execute statements */
    Connection getConnection();
    
    /** Get info about the migration being executed (when available) */
    MigrationInfo getMigrationInfo();
    
    /** Get the SQL statement being executed (for statement-level events) */
    Statement getStatement();
}

Usage Examples

// Audit callback
public class AuditCallback extends BaseCallback {
    @Override
    public void handle(Event event, Context context) {
        if (event == Event.AFTER_EACH_MIGRATE) {
            MigrationInfo info = context.getMigrationInfo();
            System.out.println("Applied migration: " + info.getVersion() + " - " + info.getDescription());
        }
    }
}

// Configuration with callbacks
Flyway flyway = Flyway.configure()
    .dataSource(dataSource)
    .callbacks(new AuditCallback(), new LoggingCallback())
    .load();

Install with Tessl CLI

npx tessl i tessl/maven-org-flywaydb--flyway-core

docs

callbacks.md

configuration.md

core-operations.md

error-handling.md

index.md

java-migrations.md

migration-info.md

tile.json