} else {
setAutoIncrement(false);
}
Table table = (Table) columnSnapshot.getRelation();
PrimaryKey primaryKey = table.getPrimaryKey();
if (primaryKey != null && primaryKey.getColumnNamesAsList().contains(columnSnapshot.getName())) {
constraints.setPrimaryKey(true);
constraints.setPrimaryKeyName(primaryKey.getName());
constraints.setPrimaryKeyTablespace(primaryKey.getTablespace());
nonDefaultConstraints = true;
}
List<UniqueConstraint> uniqueConstraints = table.getUniqueConstraints();
if (uniqueConstraints != null) {
for (UniqueConstraint constraint : uniqueConstraints) {
if (constraint.getColumnNames().contains(getName())) {
constraints.setUnique(true);
constraints.setUniqueConstraintName(constraint.getName());
nonDefaultConstraints = true;
}
}
}
List<ForeignKey> fks = table.getOutgoingForeignKeys();
if (fks != null) {
for (ForeignKey fk : fks) {
if (fk.getForeignKeyColumns() != null && fk.getForeignKeyColumns().size() == 1 && fk.getForeignKeyColumns().get(0).getName().equals(getName())) {
constraints.setForeignKeyName(fk.getName());
constraints.setReferences(fk.getPrimaryKeyTable().getName() + "(" + fk.getPrimaryKeyColumns().get(0).getName() + ")");