com.googlecode.flyway.core
Class Flyway

java.lang.Object
  extended by com.googlecode.flyway.core.Flyway

public class Flyway
extends java.lang.Object

This is the centre point of Flyway, and for most users, the only class they will ever have to deal with.

It is THE public API from which all important Flyway functions such as clean, validate and migrate can be called.


Constructor Summary
Flyway()
           
 
Method Summary
 void clean()
          Drops all objects (tables, views, procedures, triggers, ...) in the current schema.
 java.util.List<MetaDataTableRow> history()
          Returns the history (all applied migrations) of the database.
 void init(SchemaVersion initialVersion)
          Creates and initializes the Flyway metadata table.
 int migrate()
          Starts the database migration.
 void setBaseDir(java.lang.String baseDir)
           
 void setBasePackage(java.lang.String basePackage)
           
 void setDataSource(javax.sql.DataSource dataSource)
           
 void setEncoding(java.lang.String encoding)
           
 void setPlaceholderPrefix(java.lang.String placeholderPrefix)
           
 void setPlaceholders(java.util.Map<java.lang.String,java.lang.String> placeholders)
           
 void setPlaceholderSuffix(java.lang.String placeholderSuffix)
           
 void setSchemaMetaDataTable(java.lang.String table)
          Deprecated. 
 void setSqlMigrationPrefix(java.lang.String sqlMigrationPrefix)
           
 void setSqlMigrationSuffix(java.lang.String sqlMigrationSuffix)
           
 void setTable(java.lang.String table)
           
 void setValidationErrorMode(ValidationErrorMode validationErrorMode)
           
 void setValidationMode(ValidationMode validationMode)
           
 MetaDataTableRow status()
          Returns the status (current version) of the database.
 void validate()
          Validate applied migration with classpath migrations to detect accidental changes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Flyway

public Flyway()
Method Detail

setValidationMode

public void setValidationMode(ValidationMode validationMode)
Parameters:
validationMode - The ValidationMode for checksum validation

setValidationErrorMode

public void setValidationErrorMode(ValidationErrorMode validationErrorMode)
Parameters:
validationErrorMode - The error mode for validation

setBasePackage

public void setBasePackage(java.lang.String basePackage)
Parameters:
basePackage - The base package where the migrations are located. (default: db.migration)

setBaseDir

public void setBaseDir(java.lang.String baseDir)
Parameters:
baseDir - The base directory on the classpath where the Sql migrations are located. (default: sql/location)

setEncoding

public void setEncoding(java.lang.String encoding)
Parameters:
encoding - The encoding of Sql migrations. (default: UTF-8)

setSchemaMetaDataTable

@Deprecated
public void setSchemaMetaDataTable(java.lang.String table)
Deprecated. 

Deprecated (will be removed in 0.9.5). Use setTable(String table) instead.

Parameters:
table - The name of the schema metadata table that will be used by flyway. (default: schema_version)

setTable

public void setTable(java.lang.String table)
Parameters:
table - The name of the schema metadata table that will be used by flyway. (default: schema_version)

setPlaceholders

public void setPlaceholders(java.util.Map<java.lang.String,java.lang.String> placeholders)
Parameters:
placeholders - A map of to apply to sql migration scripts.

setPlaceholderPrefix

public void setPlaceholderPrefix(java.lang.String placeholderPrefix)
Parameters:
placeholderPrefix - The prefix of every placeholder. (default: ${ )

setPlaceholderSuffix

public void setPlaceholderSuffix(java.lang.String placeholderSuffix)
Parameters:
placeholderSuffix - The suffix of every placeholder. (default: } )

setSqlMigrationPrefix

public void setSqlMigrationPrefix(java.lang.String sqlMigrationPrefix)
Parameters:
sqlMigrationPrefix - The file name prefix for sql migrations (default: V)

setSqlMigrationSuffix

public void setSqlMigrationSuffix(java.lang.String sqlMigrationSuffix)
Parameters:
sqlMigrationSuffix - The file name suffix for sql migrations (default: .sql)

setDataSource

public void setDataSource(javax.sql.DataSource dataSource)
Parameters:
dataSource - The datasource to use. Must have the necessary privileges to execute ddl.

migrate

public int migrate()
            throws java.lang.Exception
Starts the database migration. All pending migrations will be applied in order.

Returns:
The number of successfully applied migrations.
Throws:
java.lang.Exception - Thrown when the migration failed.

clean

public void clean()
Drops all objects (tables, views, procedures, triggers, ...) in the current schema.


validate

public void validate()
Validate applied migration with classpath migrations to detect accidental changes. Uses validation type ALL if NONE is set.


status

public MetaDataTableRow status()
Returns the status (current version) of the database.

Returns:
The latest applied migration, or null if no migration has been applied yet.

history

public java.util.List<MetaDataTableRow> history()
Returns the history (all applied migrations) of the database.

Returns:
All migrations applied to the database, sorted, oldest first. An empty list if none.

init

public void init(SchemaVersion initialVersion)
Creates and initializes the Flyway metadata table.

Parameters:
initialVersion - (Optional) The initial version to put in the metadata table. Only migrations with a version number higher than this one will be considered for this database.


Copyright © 2010. All Rights Reserved.