public void process(SchemaChange schemaChange) {
// check all new FKs...
for (ForeignKeyConstraintCreation fkCreation : schemaChange.getSubChanges(ForeignKeyConstraintCreation.class)) {
DBForeignKeyConstraint fk = fkCreation.getAffectedObject();
String refereeTableName = fk.getRefereeTable().getName();
TableCreation refereeTableCreation = schemaChange.getSubChange(TableCreation.class, refereeTableName);
if (refereeTableCreation != null && DBUtil.containsMandatoryColumn(fk)) {
// a new 'not null' fk on an old column referring a new table makes the table creation an AUGMENTATION...
refereeTableCreation.setTypeAndSeverity("created table with mandatory reference from remaining table",
ChangeSeverity.AUGMENTATION);
refereeTableCreation.setDetails(MadUtil.formatFK(fk, false, false, false, false));
// and the reference an AUGMENTATION
fkCreation.setTypeAndSeverity("created mandatory foreign key on remaining table referencing a new table",
ChangeSeverity.AUGMENTATION);
refereeTableCreation.setDetails(MadUtil.formatFK(fk, false, false, true, false));
}
}
}