0) {
liquibase.update(changesToApply, contexts, outputWriter);
} else {
liquibase.update(contexts, outputWriter);
}
}
@Override
protected Liquibase createLiquibase(ResourceAccessor fo, Database db) throws MojoExecutionException {
Liquibase liquibase = super.createLiquibase(fo, db);
// Setup the output file writer
try {
if (!migrationSqlOutputFile.exists()) {
// Ensure the parent directories exist
migrationSqlOutputFile.getParentFile().mkdirs();
// Create the actual file
if (!migrationSqlOutputFile.createNewFile()) {
throw new MojoExecutionException("Cannot create the migration SQL file; "
+ migrationSqlOutputFile.getAbsolutePath());
}
}
outputWriter = new FileWriter(migrationSqlOutputFile);
} catch (IOException e) {
getLog().error(e);
throw new MojoExecutionException("Failed to create SQL output writer", e);
}
getLog().info("Output SQL Migration File: " + migrationSqlOutputFile.getAbsolutePath());
return liquibase;
}
@Override
protected void printSettings(String indent) {
super.printSettings(indent);
getLog().info(indent + "migrationSQLOutputFile: " + migrationSqlOutputFile);
}
@Override
protected void cleanup(Database db) {
super.cleanup(db);
if (outputWriter != null) {
try {
outputWriter.close();
} catch (IOException e) {
getLog().error(e);
}
}
}
}
]]>
values) {
if (values.size() == 1) {
return values.get(0);
} else {
return START_CONCAT + values.get(0) + SEP_CONCAT + getConcatSql(values.subList(1, values.size()))
+ END_CONCAT;
}
}
@Override
public String getDateLiteral(String isoDate) {
String returnString = isoDate;
try {
if (isDateTime(isoDate)) {
ISODateFormat isoTimestampFormat = new ISODateFormat();
DateFormat dbTimestampFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
returnString = dbTimestampFormat.format(isoTimestampFormat.parse(isoDate));
}
} catch (ParseException e) {
throw new RuntimeException("Unexpected date format: " + isoDate, e);
}
return "'" + returnString + "'";
}
@Override
public Date parseDate(String dateAsString) throws DateParseException {
]]>
();
}
public String getSchemaName() {
return schemaName;
}
public void setSchemaName(String schemaName) {
this.schemaName = StringUtils.trimToNull(schemaName);
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public List getColumns() {
return columns;
}
public void setColumns(List columns) {
this.columns = columns;
}
public void addColumn(ColumnConfig column) {
columns.add(column);
}
public void removeColumn(ColumnConfig column) {
columns.remove(column);
}
public String getWhereClause() {
]]>
foundPKs = new ArrayList();
for (Table table : snapshot.getTables()) {
ResultSet rs = databaseMetaData.getPrimaryKeys(database.convertRequestedSchemaToCatalog(schema),
database.convertRequestedSchemaToSchema(schema), table.getName());
try {
while (rs.next()) {
String tableName = rs.getString("TABLE_NAME");
]]>