@Override
public ChangeStatus checkStatus(Database database) {
ChangeStatus result = new ChangeStatus();
try {
Column column = SnapshotGeneratorFactory.getInstance().createSnapshot(new Column(Table.class, getCatalogName(), getSchemaName(), getTableName(), getColumnName()), database);
if (column == null) {
return result.unknown("Column " + getColumnName() + " does not exist");
}
result.assertComplete(column.getDefaultValue() != null, "Column "+getColumnName()+" has no default value");
if (column.getDefaultValue() == null) {
return result;
}
if (getDefaultValue() != null) {
return result.assertCorrect(getDefaultValue().equals(column.getDefaultValue()), "Default value was "+column.getDefaultValue());
} else if (getDefaultValueDate() != null) {
return result.assertCorrect(getDefaultValueDate().equals(new ISODateFormat().format((Date) column.getDefaultValue())), "Default value was "+column.getDefaultValue());
} else if (getDefaultValueNumeric() != null) {
return result.assertCorrect(getDefaultValueNumeric().equals(column.getDefaultValue().toString()), "Default value was "+column.getDefaultValue());
} else if (getDefaultValueBoolean() != null) {
return result.assertCorrect(getDefaultValueBoolean().equals(column.getDefaultValue()), "Default value was "+column.getDefaultValue());
} else if (getDefaultValueComputed() != null) {
return result.assertCorrect(getDefaultValueComputed().equals(column.getDefaultValue()), "Default value was "+column.getDefaultValue());
} else if (getDefaultValueSequenceNext() != null) {
return result.assertCorrect(getDefaultValueSequenceNext().equals(column.getDefaultValue()), "Default value was "+column.getDefaultValue());
} else {
return result.unknown("Unknown default value type");
}
} catch (Exception e) {
return result.unknown(e);