com.googlecode.flyway.core.dbsupport
Interface DbSupport

All Known Implementing Classes:
DB2DbSupport, H2DbSupport, HsqlDbSupport, MySQLDbSupport, OracleDbSupport, PostgreSQLDbSupport, SQLServerDbSupport

public interface DbSupport

Abstraction for database-specific functionality.


Method Summary
 SqlScript createCleanScript(java.lang.String schema)
          Creates a new sql script which clean this 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 getBooleanFalse()
           
 java.lang.String getBooleanTrue()
           
 java.lang.String getCurrentSchema()
          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 isSchemaEmpty(java.lang.String schema)
          Checks if this database schema is empty.
 void lockTable(java.lang.String schema, java.lang.String table)
          Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.
 boolean supportsDdlTransactions()
          Checks whether ddl transactions are supported for this database.
 boolean tableExists(java.lang.String schema, 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(java.lang.String schema)
Creates a new sql script which clean this schema, by dropping all objects.

Parameters:
schema - The schema to clean.
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.

isSchemaEmpty

boolean isSchemaEmpty(java.lang.String schema)
Checks if this database schema is empty.

Parameters:
schema - The schema to check.
Returns:
true if it is empty, false if it is not.

tableExists

boolean tableExists(java.lang.String schema,
                    java.lang.String table)
Checks whether this table is already present in the database.

Parameters:
schema - The schema in which to look.
table - The table to look for.
Returns:
true if the table exists, false if it doesn't.

getCurrentSchema

java.lang.String getCurrentSchema()
Retrieves the current schema.

Returns:
The current schema for this connection.

getCurrentUserFunction

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

supportsDdlTransactions

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

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

lockTable

void lockTable(java.lang.String schema,
               java.lang.String table)
Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.

Parameters:
schema - The schema of the table to lock.
table - The table to lock.

getBooleanTrue

java.lang.String getBooleanTrue()
Returns:
The representation of the value true in a boolean column.

getBooleanFalse

java.lang.String getBooleanFalse()
Returns:
The representation of the value false in a boolean column.


Copyright © 2011. All Rights Reserved.