@@ -68,7 +68,7 @@ const mapCheckConstraintNamesToChangeHistory = collection => {
6868 * */
6969const getDropCheckConstraintScriptDtos = ( constraintHistory , fullTableName ) => {
7070 return constraintHistory
71- . filter ( historyEntry => historyEntry . old && ! historyEntry . new )
71+ . filter ( historyEntry => historyEntry . old ?. constrExpression && ! historyEntry . new ?. constrExpression )
7272 . map ( historyEntry => {
7373 const wrappedConstraintName = wrapInQuotes ( historyEntry . old . chkConstrName ) ;
7474 return dropConstraint ( fullTableName , wrappedConstraintName ) ;
@@ -100,7 +100,7 @@ const addCheckConstraint = (tableName, constraintName, expression, noInherit = f
100100 * */
101101const getAddCheckConstraintScriptDtos = ( constraintHistory , fullTableName ) => {
102102 return constraintHistory
103- . filter ( historyEntry => historyEntry . new && ! historyEntry . old )
103+ . filter ( historyEntry => historyEntry . new ?. constrExpression && ! historyEntry . old ?. constrExpression )
104104 . map ( historyEntry => {
105105 const { chkConstrName, constrExpression, noInherit } = historyEntry . new ;
106106 return addCheckConstraint ( fullTableName , wrapInQuotes ( chkConstrName ) , constrExpression , noInherit ) ;
@@ -116,7 +116,7 @@ const getAddCheckConstraintScriptDtos = (constraintHistory, fullTableName) => {
116116const getUpdateCheckConstraintScriptDtos = ( constraintHistory , fullTableName ) => {
117117 return constraintHistory
118118 . filter ( historyEntry => {
119- if ( historyEntry . old && historyEntry . new ) {
119+ if ( historyEntry . old ?. constrExpression && historyEntry . new ?. constrExpression ) {
120120 const oldExpression = historyEntry . old . constrExpression ;
121121 const newExpression = historyEntry . new . constrExpression ;
122122 const oldNoInherit = historyEntry . old . noInherit ;
0 commit comments