com.googlecode.flyway.core.migration
Class Migration

java.lang.Object
  extended by com.googlecode.flyway.core.migration.Migration
All Implemented Interfaces:
java.lang.Comparable<Migration>
Direct Known Subclasses:
BaseMigration

public class Migration
extends java.lang.Object
implements java.lang.Comparable<Migration>

A migration of a single version of the schema.

Author:
Axel Fontaine

Field Summary
protected  java.lang.Long checksum
          The crc-32 checksum of the script.
protected  java.lang.Integer executionTime
          The time (in ms) it took to execute.
protected  java.util.Date installedOn
          The timestamp when this migration was applied to the database.
protected  MigrationState migrationState
          The state of this migration.
protected  SchemaVersion schemaVersion
          The target schema version of this migration.
protected  java.lang.String scriptName
          The script name for the migration history.
 
Constructor Summary
Migration()
           
 
Method Summary
 void assertNotFailed()
          Asserts that this migration has not failed.
 int compareTo(Migration o)
           
protected  void doMigrate(org.springframework.transaction.support.TransactionTemplate transactionTemplate, org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, DbSupport dbSupport)
          Performs the migration.
 java.lang.Long getChecksum()
           
 java.lang.Integer getExecutionTime()
           
 java.util.Date getInstalledOn()
           
 java.lang.String getScriptName()
           
 MigrationState getState()
           
 SchemaVersion getVersion()
           
 void migrate(org.springframework.transaction.support.TransactionTemplate transactionTemplate, org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, DbSupport dbSupport)
          Performs the migration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

schemaVersion

protected SchemaVersion schemaVersion
The target schema version of this migration.


migrationState

protected MigrationState migrationState
The state of this migration.


installedOn

protected java.util.Date installedOn
The timestamp when this migration was applied to the database. (Automatically set by the database)


executionTime

protected java.lang.Integer executionTime
The time (in ms) it took to execute.


scriptName

protected java.lang.String scriptName
The script name for the migration history.


checksum

protected java.lang.Long checksum
The crc-32 checksum of the script.

Constructor Detail

Migration

public Migration()
Method Detail

getChecksum

public java.lang.Long getChecksum()
Returns:
The crc-32 checksum of the script.

getVersion

public SchemaVersion getVersion()
Returns:
The schema version after the migration is complete.

getState

public MigrationState getState()
Returns:
The state of this migration.

getInstalledOn

public java.util.Date getInstalledOn()
Returns:
The timestamp when this migration was applied to the database. (Automatically set by the database)

getExecutionTime

public java.lang.Integer getExecutionTime()
Returns:
The time (in ms) it took to execute.

getScriptName

public java.lang.String getScriptName()
Returns:
The script name for the migration history.

assertNotFailed

public void assertNotFailed()
Asserts that this migration has not failed.

Throws:
java.lang.IllegalStateException - Thrown when this migration has failed.

migrate

public final void migrate(org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                          org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                          DbSupport dbSupport)
Performs the migration. The migration state and the execution time are updated accordingly.

Parameters:
transactionTemplate - The transaction template to use.
jdbcTemplate - To execute the migration statements.
dbSupport - The support for database-specific extensions.

compareTo

public int compareTo(Migration o)
Specified by:
compareTo in interface java.lang.Comparable<Migration>

doMigrate

protected void doMigrate(org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                         org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                         DbSupport dbSupport)
                  throws org.springframework.dao.DataAccessException
Performs the migration.

Parameters:
transactionTemplate - The transaction template to use.
jdbcTemplate - To execute the migration statements.
dbSupport - The support for database-specific extensions.
Throws:
org.springframework.dao.DataAccessException - Thrown when the migration failed.


Copyright © 2010. All Rights Reserved.