Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ protected void validateTable(
);
}
validateColumnType( table, column, existingColumn, metadata, dialect );
validateColumnNullability( table, column, existingColumn );
}
}

Expand All @@ -164,6 +165,22 @@ protected void validateColumnType(
}
}

private void validateColumnNullability(Table table, Column column, ColumnInformation existingColumn) {
if ( existingColumn.getNullable() == Boolean.FALSE ) {
// the existing schema column is defined as not-nullable
if ( column.isNullable() ) {
// but it is mapped in the model as nullable
throw new SchemaManagementException(
String.format(
"Schema validation: column defined as not-null in the database, but nullable in model - [%s] in table [%s]",
column.getName(),
table.getQualifiedTableName()
)
);
}
}
}

protected void validateSequence(Sequence sequence, SequenceInformation sequenceInformation) {
if ( sequenceInformation == null ) {
throw new SchemaManagementException(
Expand Down
Loading