diff --git a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/checkConstraintHelper.js b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/checkConstraintHelper.js index 77d7918..e2af925 100644 --- a/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/checkConstraintHelper.js +++ b/forward_engineering/alterScript/alterScriptHelpers/columnHelpers/checkConstraintHelper.js @@ -105,7 +105,7 @@ const mapColumnCheckConstraintsToChangeHistory = collection => { * */ const getDropColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName) => { return constraintHistory - .filter(historyEntry => historyEntry.old && !historyEntry.new) + .filter(historyEntry => historyEntry.old?.expression && !historyEntry.new?.expression) .map(historyEntry => { const wrappedConstraintName = getConstraintName( historyEntry.old.name, @@ -124,7 +124,7 @@ const getDropColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName * */ const getAddColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName) => { return constraintHistory - .filter(historyEntry => historyEntry.new && !historyEntry.old) + .filter(historyEntry => historyEntry.new?.expression && !historyEntry.old?.expression) .map(historyEntry => { const { name, expression, noInherit } = historyEntry.new; const constraintName = getConstraintName(name, historyEntry.columnName, fullTableName); @@ -142,7 +142,7 @@ const getAddColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName) const getUpdateColumnCheckConstraintScriptDtos = (constraintHistory, fullTableName) => { return constraintHistory .filter(historyEntry => { - if (historyEntry.old && historyEntry.new) { + if (historyEntry.old?.expression && historyEntry.new?.expression) { const oldExpression = historyEntry.old.expression; const newExpression = historyEntry.new.expression; const oldNoInherit = historyEntry.old.noInherit; diff --git a/forward_engineering/ddlProvider/ddlProvider.js b/forward_engineering/ddlProvider/ddlProvider.js index 01210ea..7a82aa9 100644 --- a/forward_engineering/ddlProvider/ddlProvider.js +++ b/forward_engineering/ddlProvider/ddlProvider.js @@ -224,9 +224,12 @@ module.exports = (baseProvider, options, app) => { const defaultValue = !_.isUndefined(columnDefinition.default) ? ' DEFAULT ' + decorateDefault(type, columnDefinition.default, isArrayType) : ''; - const checkConstraint = !_.isEmpty(columnDefinition.checkConstraint) - ? ' ' + this.createCheckConstraint(_.first(columnDefinition.checkConstraint)).trim() + + const checkConstraintData = _.first(columnDefinition.checkConstraint); + const checkConstraint = checkConstraintData?.expression + ? ' ' + this.createCheckConstraint(checkConstraintData).trim() : ''; + const generatedColumnClause = columnDefinition.dbVersion >= 12 && columnDefinition.generatedColumn &&