com.googlecode.flyway.core.dbsupport.mysql
Class MySQLDbSupport

java.lang.Object
  extended by com.googlecode.flyway.core.dbsupport.mysql.MySQLDbSupport
All Implemented Interfaces:
DbSupport

public class MySQLDbSupport
extends java.lang.Object
implements DbSupport

Mysql-specific support.


Constructor Summary
MySQLDbSupport(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
          Creates a new instance.
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MySQLDbSupport

public MySQLDbSupport(org.springframework.jdbc.core.JdbcTemplate jdbcTemplate)
Creates a new instance.

Parameters:
jdbcTemplate - The jdbcTemplate to use.
Method Detail

getScriptLocation

public java.lang.String getScriptLocation()
Description copied from interface: DbSupport
Returns the location on the classpath where the scripts for this database reside.

Specified by:
getScriptLocation in interface DbSupport
Returns:
The folder on the classpath, including a trailing slash.

getCurrentUserFunction

public java.lang.String getCurrentUserFunction()
Specified by:
getCurrentUserFunction in interface DbSupport
Returns:
The database function that returns the current user.

getCurrentSchema

public java.lang.String getCurrentSchema()
Description copied from interface: DbSupport
Retrieves the current schema.

Specified by:
getCurrentSchema in interface DbSupport
Returns:
The current schema for this connection.

isSchemaEmpty

public boolean isSchemaEmpty(java.lang.String schema)
Description copied from interface: DbSupport
Checks if this database schema is empty.

Specified by:
isSchemaEmpty in interface DbSupport
Parameters:
schema - The schema to check.
Returns:
true if it is empty, false if it is not.

tableExists

public boolean tableExists(java.lang.String schema,
                           java.lang.String table)
Description copied from interface: DbSupport
Checks whether this table is already present in the database.

Specified by:
tableExists in interface DbSupport
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.

supportsDdlTransactions

public boolean supportsDdlTransactions()
Description copied from interface: DbSupport
Checks whether ddl transactions are supported for this database.

Specified by:
supportsDdlTransactions in interface DbSupport
Returns:
true if ddl transactions are supported, false if not.

lockTable

public void lockTable(java.lang.String schema,
                      java.lang.String table)
Description copied from interface: DbSupport
Locks this table in this schema using a read/write pessimistic lock until the end of the current transaction.

Specified by:
lockTable in interface DbSupport
Parameters:
schema - The schema of the table to lock.
table - The table to lock.

getBooleanTrue

public java.lang.String getBooleanTrue()
Specified by:
getBooleanTrue in interface DbSupport
Returns:
The representation of the value true in a boolean column.

getBooleanFalse

public java.lang.String getBooleanFalse()
Specified by:
getBooleanFalse in interface DbSupport
Returns:
The representation of the value false in a boolean column.

createSqlScript

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

Specified by:
createSqlScript in interface DbSupport
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.

createCleanScript

public SqlScript createCleanScript(java.lang.String schema)
Description copied from interface: DbSupport
Creates a new sql script which clean this schema, by dropping all objects.

Specified by:
createCleanScript in interface DbSupport
Parameters:
schema - The schema to clean.
Returns:
A new sql script, containing drop statements for all objects


Copyright © 2011. All Rights Reserved.