Class RegistryUpdater

  • All Implemented Interfaces:
    org.flywaydb.core.api.callback.Callback

    public class RegistryUpdater
    extends Object
    implements org.flywaydb.core.api.callback.Callback
    This is a FlywayCallback class which automatically updates the Metadata Schema Registry and Bitstream Formats Registries AFTER all Database migrations occur.

    The reason this runs AFTER all migrations is that the RegistryLoader and MetadataImporter now depend on Hibernate and Hibernate cannot be initialized until the Database is fully migrated.

    If a migration needs to use on one or more registry values, there are two options:

    • Create/insert those registry values in the migration itself (via SQL or similar).
    • Alternatively, first check for the existence of the MetadataSchemaRegistry (or similar) before running the migration logic. If the table or fields do not yet exist, you might be able to skip the migration logic entirely. See "DatabaseUtils.tableExists()" and similar methods.
    Author:
    Tim Donohue
    • Constructor Summary

      Constructors 
      Constructor Description
      RegistryUpdater()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean canHandleInTransaction​(org.flywaydb.core.api.callback.Event event, org.flywaydb.core.api.callback.Context context)
      Whether event can be handled in a transaction or whether it must be handle outside of transaction.
      void handle​(org.flywaydb.core.api.callback.Event event, org.flywaydb.core.api.callback.Context context)
      What to run when the callback is triggered.
      boolean supports​(org.flywaydb.core.api.callback.Event event, org.flywaydb.core.api.callback.Context context)
      Events supported by this callback.
    • Constructor Detail

      • RegistryUpdater

        public RegistryUpdater()
    • Method Detail

      • supports

        public boolean supports​(org.flywaydb.core.api.callback.Event event,
                                org.flywaydb.core.api.callback.Context context)
        Events supported by this callback.
        Specified by:
        supports in interface org.flywaydb.core.api.callback.Callback
        Parameters:
        event - Flyway event
        context - Flyway context
        Returns:
        true if AFTER_MIGRATE event
      • canHandleInTransaction

        public boolean canHandleInTransaction​(org.flywaydb.core.api.callback.Event event,
                                              org.flywaydb.core.api.callback.Context context)
        Whether event can be handled in a transaction or whether it must be handle outside of transaction.
        Specified by:
        canHandleInTransaction in interface org.flywaydb.core.api.callback.Callback
        Parameters:
        event - Flyway event
        context - Flyway context
        Returns:
        true
      • handle

        public void handle​(org.flywaydb.core.api.callback.Event event,
                           org.flywaydb.core.api.callback.Context context)
        What to run when the callback is triggered.
        Specified by:
        handle in interface org.flywaydb.core.api.callback.Callback
        Parameters:
        event - Flyway event
        context - Flyway context