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 tableName)
          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.
 boolean exists()
          Checks whether Flyway's metadata table is already present in the database.
 boolean hasRows()
          Checks whether the metadata table contains at least one row.
 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 tableName)
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.
tableName - The name of the schema metadata table used by flyway.
Method Detail

exists

public boolean exists()
Checks whether Flyway's metadata table is already present in the database.

Returns:
true if the table exists, false if it doesn't.

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.

hasRows

public boolean hasRows()
Checks whether the metadata table contains at least one row.

Returns:
true if the metadata table has at least on row. false if it is empty or it doesn't exist yet.

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.


Copyright © 2010. All Rights Reserved.