com.googlecode.flyway.core.metadatatable
Class MetaDataTable

java.lang.Object
  extended by com.googlecode.flyway.core.metadatatable.MetaDataTable

public class MetaDataTable
extends java.lang.Object

Supports reading and writing to the metadata table.


Constructor Summary
MetaDataTable(org.springframework.transaction.support.TransactionTemplate transactionTemplate, org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, DbSupport dbSupport, java.lang.String schema, java.lang.String table)
          Creates a new instance of the metadata table support.
 
Method Summary
 java.util.List<MetaDataTableRow> allAppliedMigrations()
           
 void createIfNotExists()
          Creates the metadata table if it doesn't already exist.
 MigrationState getCurrentSchemaState()
           
 SchemaVersion getCurrentSchemaVersion()
           
 void insert(MetaDataTableRow metaDataTableRow)
          Adds this row to the metadata table and mark it as current.
 MetaDataTableRow latestAppliedMigration()
           
 void lock()
          Acquires an exclusive read-write lock on the metadata table.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaDataTable

public MetaDataTable(org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                     org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                     DbSupport dbSupport,
                     java.lang.String schema,
                     java.lang.String table)
Creates a new instance of the metadata table support.

Parameters:
transactionTemplate - The transaction template to use.
jdbcTemplate - JdbcTemplate with ddl manipulation access to the database.
dbSupport - Database-specific functionality.
schema - The schema in which the metadata table belongs.
table - The name of the schema metadata table used by flyway.
Method Detail

createIfNotExists

public void createIfNotExists()
Creates the metadata table if it doesn't already exist.


lock

public void lock()
Acquires an exclusive read-write lock on the metadata table. This lock will be released automatically on commit.


insert

public void insert(MetaDataTableRow metaDataTableRow)
Adds this row to the metadata table and mark it as current.

Parameters:
metaDataTableRow - The metaDataTableRow to add.

latestAppliedMigration

public MetaDataTableRow latestAppliedMigration()
Returns:
The latest migration applied on the schema. null if no migration has been applied so far.

allAppliedMigrations

public java.util.List<MetaDataTableRow> allAppliedMigrations()
Returns:
The list of all migrations applied on the schema (oldest first). An empty list if no migration has been applied so far.

getCurrentSchemaState

public MigrationState getCurrentSchemaState()
Returns:
The current state of the schema.

getCurrentSchemaVersion

public SchemaVersion getCurrentSchemaVersion()
Returns:
The current version of the schema.


Copyright © 2011. All Rights Reserved.