Top Description Fields Constructors Methods
liquibase.change.core

public Class SQLFileChange

extends AbstractSQLChange
Class Inheritance
Annotations
@DatabaseChange
name:sqlFile
description:Allows you to specify any SQL statement and have it stored external in a file.
priority:1
Imports
liquibase.ChecksumVersion, .GlobalConfiguration, .Scope, liquibase.change.*, liquibase.changelog.ChangeLogParameters, liquibase.database.Database, liquibase.exception.SetupException, .UnexpectedLiquibaseException, .ValidationErrors, liquibase.parser.ChangeLogParserConfiguration, liquibase.resource.Resource, .ResourceAccessor, liquibase.util.FileUtil, .ObjectUtil, .StreamUtil, .StringUtil, java.io.ByteArrayInputStream, .IOException, .InputStream, java.nio.charset.Charset

Represents a Change for custom SQL stored in a File.

Field Summary

Modifier and TypeField and Description
private Boolean
private String
private Boolean
Inherited from liquibase.change.AbstractSQLChange:
encoding

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private void
public String
describe()

Overrides liquibase.AbstractExtensibleObject.describe.

Implements liquibase.ExtensibleObject.describe.

Output a full description of this object.

public void
public CheckSum
generateCheckSum()

Overrides liquibase.change.AbstractSQLChange.generateCheckSum.

Implements liquibase.change.Change.generateCheckSum.

Calculates the checksum based on the contained SQL.

public boolean
generateRollbackStatementsVolatile(Database database)

Overrides liquibase.change.AbstractSQLChange.generateRollbackStatementsVolatile.

Implements liquibase.change.Change.generateRollbackStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateRollbackStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.

public boolean
public String
getConfirmationMessage()

Implements liquibase.change.Change.getConfirmationMessage.

Confirmation message to be displayed after the change is executed.

public String

Returns:

the encoding
getEncoding
()

The encoding of the file containing SQL statements

public String
private Resource
public String
public String
getSql()

Overrides liquibase.change.AbstractSQLChange.getSql.

Return the raw SQL managed by this Change

public String
getSql(boolean doExpandExpressions)

public Boolean
public InputStream
public void
setDoExpandExpressionsInGenerateChecksum(Boolean doExpandExpressionsInGenerateChecksum)

public void
setEncoding(String
the encoding to set
encoding
)

public void
setPath(String
The file to use
fileName
)

Sets the file name but setUp must be called for the change to have impact.

public void
setRelativeToChangelogFile(Boolean relativeToChangelogFile)

public void
setSql(String sql)

Overrides liquibase.change.AbstractSQLChange.setSql.

Set the raw SQL managed by this Change.

public ValidationErrors
validate(Database database)

Overrides liquibase.change.AbstractSQLChange.validate.

Implements liquibase.change.Change.validate.

Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to the liquibase.sqlgenerator.SqlGenerator#validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements.

Inherited from liquibase.change.AbstractSQLChange:
checkStatusgenerateStatementsgetDbmsgetEndDelimiterisIgnoreOriginalSplitStatementsisSplitStatementsisSplitStatementsSetisStripCommentsnormalizeLineEndingssetDbmssetEndDelimitersetIgnoreOriginalSplitStatementssetOriginalSplitStatementssetSplitStatementssetStripCommentssupportswarn

Field Detail

doExpandExpressionsInGenerateChecksumback to summary
private Boolean doExpandExpressionsInGenerateChecksum
pathback to summary
private String path
relativeToChangelogFileback to summary
private Boolean relativeToChangelogFile

Constructor Detail

SQLFileChangeback to summary
public SQLFileChange()

Method Detail

alertOnNonExistantSqlFileback to summary
private void alertOnNonExistantSqlFile(ValidationErrors validationErrors)
describeback to summary
public String describe()

Overrides liquibase.AbstractExtensibleObject.describe.

Implements liquibase.ExtensibleObject.describe.

Doc from liquibase.ExtensibleObject.describe.

Output a full description of this object. Should include all attributes and values.

Annotations
@Override
finishInitializationback to summary
public void finishInitialization() throws SetupException

Overrides liquibase.change.AbstractChange.finishInitialization.

Implements liquibase.change.Change.finishInitialization.

Doc from liquibase.change.AbstractChange.finishInitialization.

Default implementation is a no-op

Annotations
@Override
generateCheckSumback to summary
public CheckSum generateCheckSum()

Overrides liquibase.change.AbstractSQLChange.generateCheckSum.

Implements liquibase.change.Change.generateCheckSum.

Doc from liquibase.change.AbstractSQLChange.generateCheckSum.

Calculates the checksum based on the contained SQL.

Annotations
@Override
generateRollbackStatementsVolatileback to summary
public boolean generateRollbackStatementsVolatile(Database database)

Overrides liquibase.change.AbstractSQLChange.generateRollbackStatementsVolatile.

Implements liquibase.change.Change.generateRollbackStatementsVolatile.

Doc from liquibase.change.AbstractChange.generateRollbackStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateRollbackStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements If no or null SqlStatements are returned by generateRollbackStatements then this method returns false.

Annotations
@Override
generateStatementsVolatileback to summary
public boolean generateStatementsVolatile(Database database)

Overrides liquibase.change.AbstractSQLChange.generateStatementsVolatile.

Implements liquibase.change.Change.generateStatementsVolatile.

Doc from liquibase.change.AbstractChange.generateStatementsVolatile.

Implementation delegates logic to the liquibase.sqlgenerator.SqlGenerator#generateStatementsIsVolatile(Database) method on the SqlStatement objects returned by generateStatements. If zero or null SqlStatements are returned by generateStatements then this method returns false.

Annotations
@Override
getConfirmationMessageback to summary
public String getConfirmationMessage()

Implements liquibase.change.Change.getConfirmationMessage.

Doc from liquibase.change.Change.getConfirmationMessage.

Confirmation message to be displayed after the change is executed. Should include relevant configuration settings to make it as helpful as possible. This method may be called outside the changelog execution process, such as in documentation generation.

Annotations
@Override
getEncodingback to summary
public String getEncoding()

The encoding of the file containing SQL statements

Returns:String

the encoding

Annotations
@DatabaseChangeProperty
exampleValue:utf8
description:Encoding used in the file you specify in \'path\'
getPathback to summary
public String getPath()
Annotations
@DatabaseChangeProperty
description:The file path of the SQL file to load
exampleValue:my/path/file.sql
requiredForDatabase:all
getResourceback to summary
private Resource getResource() throws IOException
getSerializedObjectNamespaceback to summary
public String getSerializedObjectNamespace()

Overrides liquibase.change.AbstractChange.getSerializedObjectNamespace.

Implements liquibase.serializer.LiquibaseSerializable.getSerializedObjectNamespace.

Annotations
@Override
getSqlback to summary
public String getSql()

Overrides liquibase.change.AbstractSQLChange.getSql.

Doc from liquibase.change.AbstractSQLChange.getSql.

Return the raw SQL managed by this Change

Annotations
@Override
@DatabaseChangeProperty
isChangeProperty:false
getSqlback to summary
public String getSql(boolean doExpandExpressions)
isRelativeToChangelogFileback to summary
public Boolean isRelativeToChangelogFile()
Annotations
@DatabaseChangeProperty
description:Specifies whether the file path is relative to the changelog file rather than looked up in the search path. Default: false.
openSqlStreamback to summary
public InputStream openSqlStream() throws IOException

Overrides liquibase.change.AbstractSQLChange.openSqlStream.

Annotations
@Override
setDoExpandExpressionsInGenerateChecksumback to summary
public void setDoExpandExpressionsInGenerateChecksum(Boolean doExpandExpressionsInGenerateChecksum)
setEncodingback to summary
public void setEncoding(String encoding)
Parameters
encoding:String

the encoding to set

setPathback to summary
public void setPath(String fileName)

Sets the file name but setUp must be called for the change to have impact.

Parameters
fileName:String

The file to use

setRelativeToChangelogFileback to summary
public void setRelativeToChangelogFile(Boolean relativeToChangelogFile)
setSqlback to summary
public void setSql(String sql)

Overrides liquibase.change.AbstractSQLChange.setSql.

Doc from liquibase.change.AbstractSQLChange.setSql.

Set the raw SQL managed by this Change. The passed sql is trimmed and set to null if an empty string is passed.

Annotations
@Override
validateback to summary
public ValidationErrors validate(Database database)

Overrides liquibase.change.AbstractSQLChange.validate.

Implements liquibase.change.Change.validate.

Doc from liquibase.change.AbstractChange.validate.

Implementation checks the ChangeParameterMetaData for declared required fields and also delegates logic to the liquibase.sqlgenerator.SqlGenerator#validate(liquibase.statement.SqlStatement, liquibase.database.Database, liquibase.sqlgenerator.SqlGeneratorChain) method on the SqlStatement objects returned by generateStatements. If no or null SqlStatements are returned by generateStatements then this method returns no errors. If there are no parameters than this method returns no errors

Annotations
@Override