use of liquibase.change.core.SQLFileChange in project quarkus by quarkusio.
the class LiquibaseMongodbProcessor method extractChangeFile.
private Optional<String> extractChangeFile(Change change, String changeSetFilePath) {
String path = null;
Boolean relative = null;
if (change instanceof LoadDataChange) {
LoadDataChange loadDataChange = (LoadDataChange) change;
path = loadDataChange.getFile();
relative = loadDataChange.isRelativeToChangelogFile();
} else if (change instanceof SQLFileChange) {
SQLFileChange sqlFileChange = (SQLFileChange) change;
path = sqlFileChange.getPath();
relative = sqlFileChange.isRelativeToChangelogFile();
} else if (change instanceof CreateProcedureChange) {
CreateProcedureChange createProcedureChange = (CreateProcedureChange) change;
path = createProcedureChange.getPath();
relative = createProcedureChange.isRelativeToChangelogFile();
} else if (change instanceof CreateViewChange) {
CreateViewChange createViewChange = (CreateViewChange) change;
path = createViewChange.getPath();
relative = createViewChange.getRelativeToChangelogFile();
}
// unrelated change or change does not reference a file (e.g. inline view)
if (path == null) {
return Optional.empty();
}
// absolute file path or changeSet has no file path
if (relative == null || !relative || changeSetFilePath == null) {
return Optional.of(path);
}
// notes: ClassLoaderResourceAccessor does not provide a suitable method and CLRA.getFinalPath() is not visible
return Optional.of(Paths.get(changeSetFilePath).resolveSibling(path).toString().replace('\\', '/'));
}
use of liquibase.change.core.SQLFileChange in project camunda-bpm-platform by camunda.
the class SqlScriptTest method executeSqlScript.
protected void executeSqlScript(String sqlFolder, String sqlScript) throws LiquibaseException {
String statements = IoUtil.inputStreamAsString(getClass().getClassLoader().getResourceAsStream(String.format("sql/%s/%s_%s_%s.sql", sqlFolder, databaseType, sqlScript, projectVersion)));
SQLFileChange sqlFileChange = new SQLFileChange();
sqlFileChange.setSql(statements);
database.execute(sqlFileChange.generateStatements(database), null);
}
use of liquibase.change.core.SQLFileChange in project quarkus by quarkusio.
the class LiquibaseProcessor method extractChangeFile.
private Optional<String> extractChangeFile(Change change, String changeSetFilePath) {
String path = null;
Boolean relative = null;
if (change instanceof LoadDataChange) {
LoadDataChange loadDataChange = (LoadDataChange) change;
path = loadDataChange.getFile();
relative = loadDataChange.isRelativeToChangelogFile();
} else if (change instanceof SQLFileChange) {
SQLFileChange sqlFileChange = (SQLFileChange) change;
path = sqlFileChange.getPath();
relative = sqlFileChange.isRelativeToChangelogFile();
} else if (change instanceof CreateProcedureChange) {
CreateProcedureChange createProcedureChange = (CreateProcedureChange) change;
path = createProcedureChange.getPath();
relative = createProcedureChange.isRelativeToChangelogFile();
} else if (change instanceof CreateViewChange) {
CreateViewChange createViewChange = (CreateViewChange) change;
path = createViewChange.getPath();
relative = createViewChange.getRelativeToChangelogFile();
}
// unrelated change or change does not reference a file (e.g. inline view)
if (path == null) {
return Optional.empty();
}
// absolute file path or changeSet has no file path
if (relative == null || !relative || changeSetFilePath == null) {
return Optional.of(path);
}
// notes: ClassLoaderResourceAccessor does not provide a suitable method and CLRA.getFinalPath() is not visible
return Optional.of(Paths.get(changeSetFilePath).resolveSibling(path).toString().replace('\\', '/'));
}
use of liquibase.change.core.SQLFileChange in project liquibase by liquibase.
the class RollbackVisitor method checkForEmptyRollbackFile.
private void checkForEmptyRollbackFile(ChangeSet changeSet) {
RollbackContainer container = changeSet.getRollback();
List<Change> changes = container.getChanges();
if (changes.isEmpty()) {
return;
}
for (Change change : changes) {
if (!(change instanceof SQLFileChange)) {
continue;
}
String sql = ((SQLFileChange) change).getSql();
if (sql.length() == 0) {
Scope.getCurrentScope().getLog(getClass()).info("\nNo rollback logic defined in empty rollback script. Changesets have been removed from\n" + "the DATABASECHANGELOG table but no other logic was performed.");
}
}
}
Aggregations