com.googlecode.flyway.core.migration
Class DbMigrator

java.lang.Object
  extended by com.googlecode.flyway.core.migration.DbMigrator

public class DbMigrator
extends java.lang.Object

Main workflow for migrating the database.

Author:
Axel Fontaine

Constructor Summary
DbMigrator(org.springframework.transaction.support.TransactionTemplate transactionTemplate, org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, DbSupport dbSupport, MetaDataTable metaDataTable)
          Creates a new database migrator.
 
Method Summary
 MetaDataTableRow applyMigration(Migration migration, org.springframework.transaction.support.TransactionTemplate transactionTemplate, org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, DbSupport dbSupport)
          Applies this migration to the database.
 void init(SchemaVersion version, java.lang.String description)
          Initializes the metadata table with this version and this description.
 int migrate(java.util.List<Migration> migrations)
          Starts the actual migration.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbMigrator

public DbMigrator(org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                  org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                  DbSupport dbSupport,
                  MetaDataTable metaDataTable)
Creates a new database migrator.

Parameters:
transactionTemplate - The transaction template to use.
jdbcTemplate - JdbcTemplate with ddl manipulation access to the database.
dbSupport - Database-specific functionality.
metaDataTable - The database metadata table.
Method Detail

init

public void init(SchemaVersion version,
                 java.lang.String description)
Initializes the metadata table with this version and this description.

Parameters:
version - The version to initialize the metadata table with.
description - The description for the ionitial version.

migrate

public int migrate(java.util.List<Migration> migrations)
            throws java.lang.Exception
Starts the actual migration.

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

applyMigration

public final MetaDataTableRow applyMigration(Migration migration,
                                             org.springframework.transaction.support.TransactionTemplate transactionTemplate,
                                             org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                                             DbSupport dbSupport)
Applies this migration to the database. The migration state and the execution time are updated accordingly.

Parameters:
migration - The migration to apply.
transactionTemplate - The transaction template to use.
jdbcTemplate - To execute the migration statements.
dbSupport - The support for database-specific extensions.
Returns:
The row that was added to the metadata table.


Copyright © 2010. All Rights Reserved.