@@ -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,12 @@ const addCheckConstraint = (tableName, constraintName, expression, noInherit = f
100100 * */
101101const getAddCheckConstraintScriptDtos = ( constraintHistory , fullTableName ) => {
102102 return constraintHistory
103- . filter ( historyEntry => historyEntry . new && ! historyEntry . old )
103+ . filter (
104+ historyEntry =>
105+ historyEntry . new ?. chkConstrName &&
106+ historyEntry . new ?. constrExpression &&
107+ ! historyEntry . old ?. constrExpression ,
108+ )
104109 . map ( historyEntry => {
105110 const { chkConstrName, constrExpression, noInherit } = historyEntry . new ;
106111 return addCheckConstraint ( fullTableName , wrapInQuotes ( chkConstrName ) , constrExpression , noInherit ) ;
@@ -116,7 +121,7 @@ const getAddCheckConstraintScriptDtos = (constraintHistory, fullTableName) => {
116121const getUpdateCheckConstraintScriptDtos = ( constraintHistory , fullTableName ) => {
117122 return constraintHistory
118123 . filter ( historyEntry => {
119- if ( historyEntry . old && historyEntry . new ) {
124+ if ( historyEntry . old ?. constrExpression && historyEntry . new ?. constrExpression ) {
120125 const oldExpression = historyEntry . old . constrExpression ;
121126 const newExpression = historyEntry . new . constrExpression ;
122127 const oldNoInherit = historyEntry . old . noInherit ;
0 commit comments