Class UpgradeMetaProcessor

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public class UpgradeMetaProcessor
    extends Object
    implements Closeable
    This class determines what upgrades (if any) have already been executed against the current database and documents upgrades that are being installed so that an audit trail of the execution history is maintained.
    Since:
    1.2.0
    Author:
    Steve Springett
    • Constructor Detail

      • UpgradeMetaProcessor

        public UpgradeMetaProcessor​(Connection connection)
        Constructs a new UpgradeMetaProcessor object
        Parameters:
        connection - a SQL Connection object
        Since:
        1.2.0
      • UpgradeMetaProcessor

        public UpgradeMetaProcessor()
                             throws UpgradeException
        Constructs a new UpgradeMetaProcessor object along with a new SQL Connection object.
        Throws:
        UpgradeException - when an error occurs creating a Connection object
        Since:
        1.8.0
    • Method Detail

      • hasUpgradeRan

        public boolean hasUpgradeRan​(Class<? extends UpgradeItem> upgradeClass)
                              throws SQLException
        Determines if the specified upgrade already has a record of being executed previously or not.
        Parameters:
        upgradeClass - the class to check fi an upgrade has previously executed
        Returns:
        true if already executed, false if not
        Throws:
        SQLException - a SQLException
        Since:
        1.2.0
      • installUpgrade

        public void installUpgrade​(Class<? extends UpgradeItem> upgradeClass,
                                   long startTime,
                                   long endTime)
                            throws SQLException
        Documents a record in the database for the specified class indicating it has been executed.
        Parameters:
        upgradeClass - the name of the upgrade class
        startTime - the time (in millis) of the execution
        endTime - the time (in millis) the execution completed
        Throws:
        SQLException - a SQLException
        Since:
        1.2.0
      • getSchemaVersion

        public VersionComparator getSchemaVersion()
        Retrieves the current schema version documented in the database.
        Returns:
        A VersionComparator of the schema version
        Since:
        1.2.0
      • updateSchemaVersion

        public void updateSchemaVersion​(VersionComparator version)
                                 throws SQLException
        Updates the schema version in the database.
        Parameters:
        version - the version to set the schema to
        Throws:
        SQLException - a SQLException
        Since:
        1.2.0
      • close

        public void close()
        Closing a Connection object should only be done when this class creates the Connection and not when a Connection is passed to this objects constructor.
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable