Package alpine.upgrade
Class UpgradeMetaProcessor
- java.lang.Object
-
- alpine.upgrade.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 Summary
Constructors Constructor Description UpgradeMetaProcessor()Constructs a new UpgradeMetaProcessor object along with a new SQL Connection object.UpgradeMetaProcessor(Connection connection)Constructs a new UpgradeMetaProcessor object
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()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.VersionComparatorgetSchemaVersion()Retrieves the current schema version documented in the database.booleanhasUpgradeRan(Class<? extends UpgradeItem> upgradeClass)Determines if the specified upgrade already has a record of being executed previously or not.voidinstallUpgrade(Class<? extends UpgradeItem> upgradeClass, long startTime, long endTime)Documents a record in the database for the specified class indicating it has been executed.voidupdateSchemaVersion(VersionComparator version)Updates the schema version in the database.
-
-
-
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 UpgradeExceptionConstructs 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 classstartTime- the time (in millis) of the executionendTime- 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:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
-