Search in sources :

Example 1 with DatabaseChangeProperty

use of liquibase.change.DatabaseChangeProperty in project liquibase by liquibase.

the class SQLFileChange method getSql.

@Override
@DatabaseChangeProperty(isChangeProperty = false)
public String getSql() {
    String sql = super.getSql();
    if (sql == null) {
        InputStream sqlStream;
        try {
            sqlStream = openSqlStream();
            if (sqlStream == null) {
                return null;
            }
            String content = StreamUtil.readStreamAsString(sqlStream, getEncoding());
            if (getChangeSet() != null) {
                ChangeLogParameters parameters = getChangeSet().getChangeLogParameters();
                if (parameters != null) {
                    content = parameters.expandExpressions(content, getChangeSet().getChangeLog());
                }
            }
            return content;
        } catch (IOException e) {
            throw new UnexpectedLiquibaseException(e);
        }
    } else {
        return sql;
    }
}
Also used : InputStream(java.io.InputStream) ChangeLogParameters(liquibase.changelog.ChangeLogParameters) IOException(java.io.IOException) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) DatabaseChangeProperty(liquibase.change.DatabaseChangeProperty)

Aggregations

IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 DatabaseChangeProperty (liquibase.change.DatabaseChangeProperty)1 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)1 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)1