com.googlecode.flyway.core.dbsupport
Interface DbSupport

All Known Implementing Classes:
H2DbSupport, HsqlDbSupport, MySQLDbSupport, OracleDbSupport

public interface DbSupport

Abstraction for database-specific functionality.


Method Summary
 boolean columnExists(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, java.lang.String table, java.lang.String column)
          Checks whether this column is already present in this table in the database.
 SqlScript createCleanScript(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
          Creates a new sql script which clean the current schema, by dropping all objects.
 SqlScript createSqlScript(java.lang.String sqlScriptSource, PlaceholderReplacer placeholderReplacer)
          Creates a new sql script from this resource with these placeholders to replace.
 java.lang.String getCurrentSchema(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
          Retrieves the current schema.
 java.lang.String getCurrentUserFunction()
           
 java.lang.String getScriptLocation()
          Returns the location on the classpath where the scripts for this database reside.
 boolean supportsDatabase(java.lang.String databaseProductName)
          Checks whether this DbSupport class supports the database with this product name.
 boolean supportsDdlTransactions()
          Checks whether ddl transactions are supported for this database.
 boolean supportsLocking()
          Checks whether locking using select ... for update is supported for this database.
 boolean tableExists(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate, java.lang.String table)
          Checks whether this table is already present in the database.
 

Method Detail

createSqlScript

SqlScript createSqlScript(java.lang.String sqlScriptSource,
                          PlaceholderReplacer placeholderReplacer)
Creates a new sql script from this resource with these placeholders to replace.

Parameters:
sqlScriptSource - The sql script as a text block with all placeholders still present.
placeholderReplacer - The placeholder replacer to apply to sql migration scripts.
Returns:
A new sql script, containing the statements from this resource, with all placeholders replaced.
Throws:
java.lang.IllegalStateException - Thrown when the script could not be read from this resource.

createCleanScript

SqlScript createCleanScript(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
Creates a new sql script which clean the current schema, by dropping all objects.

Parameters:
jdbcTemplate - The jdbc template used for querying the database.
Returns:
A new sql script, containing drop statements for all objects

getScriptLocation

java.lang.String getScriptLocation()
Returns the location on the classpath where the scripts for this database reside.

Returns:
The folder on the classpath, including a trailing slash.

tableExists

boolean tableExists(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                    java.lang.String table)
Checks whether this table is already present in the database.

Parameters:
jdbcTemplate - The jdbc template used for querying the database.
table - The table to look for.
Returns:
true if the table exists, false if it doesn't.

columnExists

boolean columnExists(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate,
                     java.lang.String table,
                     java.lang.String column)
Checks whether this column is already present in this table in the database.

Parameters:
jdbcTemplate - The jdbc template used for querying the database.
table - The table to look for.
column - The column to look for.
Returns:
true if the table exists, false if it doesn't.

getCurrentSchema

java.lang.String getCurrentSchema(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
Retrieves the current schema.

Parameters:
jdbcTemplate - The jdbc template used for querying the database.
Returns:
The current schema for this connection.

getCurrentUserFunction

java.lang.String getCurrentUserFunction()
Returns:
The database function that returns the current user.

supportsDatabase

boolean supportsDatabase(java.lang.String databaseProductName)
Checks whether this DbSupport class supports the database with this product name.

Parameters:
databaseProductName - The name of the database.
Returns:
true if the database is supported, false if not.

supportsDdlTransactions

boolean supportsDdlTransactions()
Checks whether ddl transactions are supported for this database.

Returns:
true if ddl transactions are supported, false if not.

supportsLocking

boolean supportsLocking()
Checks whether locking using select ... for update is supported for this database.

Returns:
true if locking is supported, false if not.


Copyright © 2010. All Rights Reserved.