liquibase
Class Liquibase

java.lang.Object
  extended by liquibase.Liquibase

public class Liquibase
extends Object

Primary facade class for interacting with Liquibase. The built in command line, Ant, Maven and other ways of running Liquibase are wrappers around methods in this class.


Field Summary
protected  Database database
           
 
Constructor Summary
Liquibase(DatabaseChangeLog changeLog, ResourceAccessor resourceAccessor, Database database)
           
Liquibase(String changeLogFile, ResourceAccessor resourceAccessor, Database database)
          Creates a Liquibase instance.
Liquibase(String changeLogFile, ResourceAccessor resourceAccessor, DatabaseConnection conn)
          Creates a Liquibase instance for a given DatabaseConnection.
 
Method Summary
 CheckSum calculateCheckSum(String changeSetIdentifier)
           
 CheckSum calculateCheckSum(String filename, String id, String author)
           
 void changeLogSync(Contexts contexts)
           
 void changeLogSync(Contexts contexts, Writer output)
           
 void changeLogSync(String contexts)
           
 void changeLogSync(String contexts, Writer output)
           
 void checkLiquibaseTables(boolean updateExistingNullChecksums, DatabaseChangeLog databaseChangeLog, Contexts contexts)
           
 void clearCheckSums()
          Sets checksums to null so they will be repopulated next run
protected  UpdateVisitor createUpdateVisitor()
           
 DiffResult diff(Database referenceDatabase, Database targetDatabase, CompareControl compareControl)
           
 void dropAll()
          Drops all database objects owned by the current user.
 void dropAll(CatalogAndSchema... schemas)
          Drops all database objects owned by the current user.
 void forceReleaseLocks()
           
 void futureRollbackSQL(Integer count, Contexts contexts, Writer output)
           
 void futureRollbackSQL(Integer count, String contexts, Writer output)
           
 void futureRollbackSQL(String contexts, Writer output)
           
 void generateChangeLog(CatalogAndSchema catalogAndSchema, DiffToChangeLog changeLogWriter, PrintStream outputStream, ChangeLogSerializer changeLogSerializer, Class<? extends DatabaseObject>... snapshotTypes)
           
 void generateChangeLog(CatalogAndSchema catalogAndSchema, DiffToChangeLog changeLogWriter, PrintStream outputStream, Class<? extends DatabaseObject>... snapshotTypes)
           
 void generateDocumentation(String outputDirectory)
           
 void generateDocumentation(String outputDirectory, Contexts contexts)
           
 void generateDocumentation(String outputDirectory, String contexts)
           
 String getChangeLogFile()
          Return the change log file used by this Liquibase instance.
 ChangeLogParameters getChangeLogParameters()
          Returns the ChangeLogParameters container used by this Liquibase instance.
 List<ChangeSetStatus> getChangeSetStatuses(Contexts contexts)
          Returns the ChangeSetStatuses of all changesets in the change log file and history in the order they would be ran.
 Database getDatabase()
          Returns the Database used by this Liquibase instance.
 DatabaseChangeLog getDatabaseChangeLog()
           
 ResourceAccessor getFileOpener()
          Deprecated. use the newer-terminology version getResourceAccessor()
 Logger getLog()
          Return the log used by this Liquibase instance.
 ResourceAccessor getResourceAccessor()
          Return ResourceAccessor used by this Liquibase instance.
protected  ChangeLogIterator getStandardChangelogIterator(Contexts contexts, DatabaseChangeLog changeLog)
           
 boolean isIgnoreClasspathPrefix()
           
 boolean isSafeToRunUpdate()
          Returns true if it is "save" to migrate the database.
 DatabaseChangeLogLock[] listLocks()
          Display change log lock information.
 Collection<RanChangeSet> listUnexpectedChangeSets(Contexts contexts)
           
 Collection<RanChangeSet> listUnexpectedChangeSets(String contexts)
           
 List<ChangeSet> listUnrunChangeSets(Contexts contexts)
           
 List<ChangeSet> listUnrunChangeSets(String contexts)
           
 void markNextChangeSetRan(Contexts contexts)
           
 void markNextChangeSetRan(Contexts contexts, Writer output)
           
 void markNextChangeSetRan(String contexts)
           
 void markNextChangeSetRan(String contexts, Writer output)
           
 void reportLocks(PrintStream out)
           
 void reportStatus(boolean verbose, Contexts contexts, Writer out)
           
 void reportStatus(boolean verbose, String contexts, Writer out)
           
 void reportUnexpectedChangeSets(boolean verbose, Contexts contexts, Writer out)
           
 void reportUnexpectedChangeSets(boolean verbose, String contexts, Writer out)
           
 void rollback(Date dateToRollBackTo, Contexts contexts)
           
 void rollback(Date dateToRollBackTo, Contexts contexts, Writer output)
           
 void rollback(Date dateToRollBackTo, String contexts)
           
 void rollback(Date dateToRollBackTo, String contexts, Writer output)
           
 void rollback(int changesToRollback, Contexts contexts)
           
 void rollback(int changesToRollback, Contexts contexts, Writer output)
           
 void rollback(int changesToRollback, String contexts)
           
 void rollback(int changesToRollback, String contexts, Writer output)
           
 void rollback(String tagToRollBackTo, Contexts contexts)
           
 void rollback(String tagToRollBackTo, Contexts contexts, Writer output)
           
 void rollback(String tagToRollBackTo, String contexts)
           
 void rollback(String tagToRollBackTo, String contexts, Writer output)
           
 void setChangeExecListener(ChangeExecListener listener)
           
 void setChangeLogParameter(String key, Object value)
           
 void setChangeLogSyncListener(ChangeLogSyncListener changeLogSyncListener)
           
 void setCurrentDateTimeFunction(String currentDateTimeFunction)
          Deprecated. Should call Database.setCurrentDateTimeFunction(String) directly
 void setIgnoreClasspathPrefix(boolean ignoreClasspathPrefix)
           
 void tag(String tagString)
          'Tags' the database for future rollback
 void update(Contexts contexts)
          Executes Liquibase "update" logic which ensures that the configured Database is up to date according to the configured changelog file.
 void update(Contexts contexts, Writer output)
           
 void update(int changesToApply, Contexts contexts)
           
 void update(int changesToApply, Contexts contexts, Writer output)
           
 void update(int changesToApply, String contexts)
           
 void update(int changesToApply, String contexts, Writer output)
           
 void update(String contexts)
          Convience method for update(Contexts) that constructs the Context object from the passed string.
 void update(String contexts, Writer output)
           
 void updateTestingRollback(Contexts contexts)
           
 void updateTestingRollback(String contexts)
           
 void validate()
          Checks changelogs for bad MD5Sums and preconditions before attempting a migration
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

database

protected Database database
Constructor Detail

Liquibase

public Liquibase(String changeLogFile,
                 ResourceAccessor resourceAccessor,
                 DatabaseConnection conn)
          throws LiquibaseException
Creates a Liquibase instance for a given DatabaseConnection. The Database instance used will be found with DatabaseFactory.findCorrectDatabaseImplementation(liquibase.database.DatabaseConnection)

Throws:
LiquibaseException
See Also:
Liquibase(String, liquibase.resource.ResourceAccessor, liquibase.database.Database), ResourceAccessor

Liquibase

public Liquibase(String changeLogFile,
                 ResourceAccessor resourceAccessor,
                 Database database)
          throws LiquibaseException
Creates a Liquibase instance. The changeLogFile parameter must be a path that can be resolved by the passed ResourceAccessor. If windows style path separators are used for the changeLogFile, they will be standardized to unix style for better cross-system compatib.

Throws:
LiquibaseException
See Also:
ResourceAccessor

Liquibase

public Liquibase(DatabaseChangeLog changeLog,
                 ResourceAccessor resourceAccessor,
                 Database database)
Method Detail

getChangeLogFile

public String getChangeLogFile()
Return the change log file used by this Liquibase instance.


getLog

public Logger getLog()
Return the log used by this Liquibase instance.


getChangeLogParameters

public ChangeLogParameters getChangeLogParameters()
Returns the ChangeLogParameters container used by this Liquibase instance.


getDatabase

public Database getDatabase()
Returns the Database used by this Liquibase instance.


getFileOpener

public ResourceAccessor getFileOpener()
Deprecated. use the newer-terminology version getResourceAccessor()

Return ResourceAccessor used by this Liquibase instance.


getResourceAccessor

public ResourceAccessor getResourceAccessor()
Return ResourceAccessor used by this Liquibase instance.


setCurrentDateTimeFunction

public void setCurrentDateTimeFunction(String currentDateTimeFunction)
Deprecated. Should call Database.setCurrentDateTimeFunction(String) directly

Use this function to override the current date/time function used to insert dates into the database. Especially useful when using an unsupported database.


update

public void update(String contexts)
            throws LiquibaseException
Convience method for update(Contexts) that constructs the Context object from the passed string.

Throws:
LiquibaseException

update

public void update(Contexts contexts)
            throws LiquibaseException
Executes Liquibase "update" logic which ensures that the configured Database is up to date according to the configured changelog file. To run in "no context mode", pass a null or empty context object.

Throws:
LiquibaseException

getDatabaseChangeLog

public DatabaseChangeLog getDatabaseChangeLog()
                                       throws LiquibaseException
Throws:
LiquibaseException

createUpdateVisitor

protected UpdateVisitor createUpdateVisitor()

getStandardChangelogIterator

protected ChangeLogIterator getStandardChangelogIterator(Contexts contexts,
                                                         DatabaseChangeLog changeLog)
                                                  throws DatabaseException
Throws:
DatabaseException

update

public void update(String contexts,
                   Writer output)
            throws LiquibaseException
Throws:
LiquibaseException

update

public void update(Contexts contexts,
                   Writer output)
            throws LiquibaseException
Throws:
LiquibaseException

update

public void update(int changesToApply,
                   String contexts)
            throws LiquibaseException
Throws:
LiquibaseException

update

public void update(int changesToApply,
                   Contexts contexts)
            throws LiquibaseException
Throws:
LiquibaseException

update

public void update(int changesToApply,
                   String contexts,
                   Writer output)
            throws LiquibaseException
Throws:
LiquibaseException

update

public void update(int changesToApply,
                   Contexts contexts,
                   Writer output)
            throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(int changesToRollback,
                     String contexts,
                     Writer output)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(int changesToRollback,
                     Contexts contexts,
                     Writer output)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(int changesToRollback,
                     String contexts)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(int changesToRollback,
                     Contexts contexts)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(String tagToRollBackTo,
                     String contexts,
                     Writer output)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(String tagToRollBackTo,
                     Contexts contexts,
                     Writer output)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(String tagToRollBackTo,
                     String contexts)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(String tagToRollBackTo,
                     Contexts contexts)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(Date dateToRollBackTo,
                     String contexts,
                     Writer output)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(Date dateToRollBackTo,
                     Contexts contexts,
                     Writer output)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(Date dateToRollBackTo,
                     String contexts)
              throws LiquibaseException
Throws:
LiquibaseException

rollback

public void rollback(Date dateToRollBackTo,
                     Contexts contexts)
              throws LiquibaseException
Throws:
LiquibaseException

changeLogSync

public void changeLogSync(String contexts,
                          Writer output)
                   throws LiquibaseException
Throws:
LiquibaseException

changeLogSync

public void changeLogSync(Contexts contexts,
                          Writer output)
                   throws LiquibaseException
Throws:
LiquibaseException

changeLogSync

public void changeLogSync(String contexts)
                   throws LiquibaseException
Throws:
LiquibaseException

changeLogSync

public void changeLogSync(Contexts contexts)
                   throws LiquibaseException
Throws:
LiquibaseException

markNextChangeSetRan

public void markNextChangeSetRan(String contexts,
                                 Writer output)
                          throws LiquibaseException
Throws:
LiquibaseException

markNextChangeSetRan

public void markNextChangeSetRan(Contexts contexts,
                                 Writer output)
                          throws LiquibaseException
Throws:
LiquibaseException

markNextChangeSetRan

public void markNextChangeSetRan(String contexts)
                          throws LiquibaseException
Throws:
LiquibaseException

markNextChangeSetRan

public void markNextChangeSetRan(Contexts contexts)
                          throws LiquibaseException
Throws:
LiquibaseException

futureRollbackSQL

public void futureRollbackSQL(String contexts,
                              Writer output)
                       throws LiquibaseException
Throws:
LiquibaseException

futureRollbackSQL

public void futureRollbackSQL(Integer count,
                              String contexts,
                              Writer output)
                       throws LiquibaseException
Throws:
LiquibaseException

futureRollbackSQL

public void futureRollbackSQL(Integer count,
                              Contexts contexts,
                              Writer output)
                       throws LiquibaseException
Throws:
LiquibaseException

dropAll

public final void dropAll()
                   throws DatabaseException,
                          LockException
Drops all database objects owned by the current user.

Throws:
DatabaseException
LockException

dropAll

public final void dropAll(CatalogAndSchema... schemas)
                   throws DatabaseException
Drops all database objects owned by the current user.

Throws:
DatabaseException

tag

public void tag(String tagString)
         throws LiquibaseException
'Tags' the database for future rollback

Throws:
LiquibaseException

updateTestingRollback

public void updateTestingRollback(String contexts)
                           throws LiquibaseException
Throws:
LiquibaseException

updateTestingRollback

public void updateTestingRollback(Contexts contexts)
                           throws LiquibaseException
Throws:
LiquibaseException

checkLiquibaseTables

public void checkLiquibaseTables(boolean updateExistingNullChecksums,
                                 DatabaseChangeLog databaseChangeLog,
                                 Contexts contexts)
                          throws LiquibaseException
Throws:
LiquibaseException

isSafeToRunUpdate

public boolean isSafeToRunUpdate()
                          throws DatabaseException
Returns true if it is "save" to migrate the database. Currently, "safe" is defined as running in an output-sql mode or against a database on localhost. It is fine to run Liquibase against a "non-safe" database, the method is mainly used to determine if the user should be prompted before continuing.

Throws:
DatabaseException

listLocks

public DatabaseChangeLogLock[] listLocks()
                                  throws LiquibaseException
Display change log lock information.

Throws:
LiquibaseException

reportLocks

public void reportLocks(PrintStream out)
                 throws LiquibaseException
Throws:
LiquibaseException

forceReleaseLocks

public void forceReleaseLocks()
                       throws LiquibaseException
Throws:
LiquibaseException

listUnrunChangeSets

public List<ChangeSet> listUnrunChangeSets(String contexts)
                                    throws LiquibaseException
Throws:
LiquibaseException

listUnrunChangeSets

public List<ChangeSet> listUnrunChangeSets(Contexts contexts)
                                    throws LiquibaseException
Throws:
LiquibaseException

getChangeSetStatuses

public List<ChangeSetStatus> getChangeSetStatuses(Contexts contexts)
                                           throws LiquibaseException
Returns the ChangeSetStatuses of all changesets in the change log file and history in the order they would be ran.

Throws:
LiquibaseException

reportStatus

public void reportStatus(boolean verbose,
                         String contexts,
                         Writer out)
                  throws LiquibaseException
Throws:
LiquibaseException

reportStatus

public void reportStatus(boolean verbose,
                         Contexts contexts,
                         Writer out)
                  throws LiquibaseException
Throws:
LiquibaseException

listUnexpectedChangeSets

public Collection<RanChangeSet> listUnexpectedChangeSets(String contexts)
                                                  throws LiquibaseException
Throws:
LiquibaseException

listUnexpectedChangeSets

public Collection<RanChangeSet> listUnexpectedChangeSets(Contexts contexts)
                                                  throws LiquibaseException
Throws:
LiquibaseException

reportUnexpectedChangeSets

public void reportUnexpectedChangeSets(boolean verbose,
                                       String contexts,
                                       Writer out)
                                throws LiquibaseException
Throws:
LiquibaseException

reportUnexpectedChangeSets

public void reportUnexpectedChangeSets(boolean verbose,
                                       Contexts contexts,
                                       Writer out)
                                throws LiquibaseException
Throws:
LiquibaseException

clearCheckSums

public void clearCheckSums()
                    throws LiquibaseException
Sets checksums to null so they will be repopulated next run

Throws:
LiquibaseException

calculateCheckSum

public final CheckSum calculateCheckSum(String changeSetIdentifier)
                                 throws LiquibaseException
Throws:
LiquibaseException

calculateCheckSum

public CheckSum calculateCheckSum(String filename,
                                  String id,
                                  String author)
                           throws LiquibaseException
Throws:
LiquibaseException

generateDocumentation

public void generateDocumentation(String outputDirectory)
                           throws LiquibaseException
Throws:
LiquibaseException

generateDocumentation

public void generateDocumentation(String outputDirectory,
                                  String contexts)
                           throws LiquibaseException
Throws:
LiquibaseException

generateDocumentation

public void generateDocumentation(String outputDirectory,
                                  Contexts contexts)
                           throws LiquibaseException
Throws:
LiquibaseException

diff

public DiffResult diff(Database referenceDatabase,
                       Database targetDatabase,
                       CompareControl compareControl)
                throws LiquibaseException
Throws:
LiquibaseException

validate

public void validate()
              throws LiquibaseException
Checks changelogs for bad MD5Sums and preconditions before attempting a migration

Throws:
LiquibaseException

setChangeLogParameter

public void setChangeLogParameter(String key,
                                  Object value)

setChangeExecListener

public void setChangeExecListener(ChangeExecListener listener)

setChangeLogSyncListener

public void setChangeLogSyncListener(ChangeLogSyncListener changeLogSyncListener)

setIgnoreClasspathPrefix

public void setIgnoreClasspathPrefix(boolean ignoreClasspathPrefix)

isIgnoreClasspathPrefix

public boolean isIgnoreClasspathPrefix()

generateChangeLog

public void generateChangeLog(CatalogAndSchema catalogAndSchema,
                              DiffToChangeLog changeLogWriter,
                              PrintStream outputStream,
                              Class<? extends DatabaseObject>... snapshotTypes)
                       throws DatabaseException,
                              IOException,
                              ParserConfigurationException
Throws:
DatabaseException
IOException
ParserConfigurationException

generateChangeLog

public void generateChangeLog(CatalogAndSchema catalogAndSchema,
                              DiffToChangeLog changeLogWriter,
                              PrintStream outputStream,
                              ChangeLogSerializer changeLogSerializer,
                              Class<? extends DatabaseObject>... snapshotTypes)
                       throws DatabaseException,
                              IOException,
                              ParserConfigurationException
Throws:
DatabaseException
IOException
ParserConfigurationException


Copyright © 2014 Liquibase.org. All Rights Reserved.