@@ -344,10 +344,10 @@ const getColumns = (jsonSchema, areColumnConstraintsAvailable, definitions) => {
344344 return { columns, deactivatedColumnNames } ;
345345} ;
346346
347- const getColumnStatementParts = ( { collection, column } ) => {
347+ const getColumnStatementParts = ( { collection, column, isAlterScript } ) => {
348348 const { name, type, comment, isActivated, isParentActivated } = column ;
349349 const commentStatement = comment ? ` COMMENT '${ encodeStringLiteral ( comment ) } '` : '' ;
350- const { inline, separate } = getColumnConstraintsStatement ( { collection, column } ) ;
350+ const { inline, separate } = getColumnConstraintsStatement ( { collection, column, isAlterScript } ) ;
351351 const isColumnActivated = isParentActivated ? isActivated : true ;
352352
353353 return {
@@ -356,27 +356,28 @@ const getColumnStatementParts = ({ collection, column }) => {
356356 } ;
357357} ;
358358
359- const getColumnsStatement = ( { collection, columns, isParentActivated } ) => {
359+ const getColumnsStatement = ( { collection, columns, isParentActivated, isAlterScript } ) => {
360360 const columnStatements = [ ] ;
361361 const constraintStatements = [ ] ;
362362
363363 for ( const name of Object . keys ( columns ) ) {
364364 const { columnStatement, constraintsStatement } = getColumnStatementParts ( {
365365 collection,
366366 column : { ...columns [ name ] , name, isParentActivated } ,
367+ isAlterScript,
367368 } ) ;
368369
369370 columnStatements . push ( columnStatement ) ;
370371
371- if ( constraintsStatement ) {
372+ if ( ! isAlterScript && constraintsStatement ) {
372373 constraintStatements . push ( constraintsStatement ) ;
373374 }
374375 }
375376
376377 return [ ...columnStatements , ...constraintStatements ] . join ( ',\n' ) ;
377378} ;
378379
379- const getColumnConstraintsStatement = ( { collection, column } ) => {
380+ const getColumnConstraintsStatement = ( { collection, column, isAlterScript } ) => {
380381 const result = {
381382 inline : '' ,
382383 separate : '' ,
@@ -431,7 +432,7 @@ const getColumnConstraintsStatement = ({ collection, column }) => {
431432 ) ;
432433 }
433434
434- if ( defaultValue ) {
435+ if ( defaultValue && ! isAlterScript ) {
435436 result . inline = ` DEFAULT ${ defaultValue } ` ;
436437 }
437438
0 commit comments