@@ -32,6 +32,7 @@ module.exports = (baseProvider, options, app) => {
3232 foreignActiveKeysToString,
3333 createKeyConstraint,
3434 getConstraintsWarnings,
35+ additionalPropertiesForForeignKey,
3536 } = require ( './helpers/constraintsHelper' ) ( {
3637 _,
3738 commentIfDeactivated,
@@ -322,6 +323,7 @@ module.exports = (baseProvider, options, app) => {
322323 foreignTableActivated,
323324 foreignSchemaName,
324325 primarySchemaName,
326+ customProperties
325327 } ,
326328 dbData ,
327329 schemaData ,
@@ -334,11 +336,16 @@ module.exports = (baseProvider, options, app) => {
334336 primaryTableActivated &&
335337 foreignTableActivated ;
336338
339+ const { foreignOnDelete, foreignOnUpdate, foreignMatch } = additionalPropertiesForForeignKey ( customProperties ) ;
340+
337341 const foreignKeyStatement = assignTemplates ( templates . createForeignKeyConstraint , {
338342 primaryTable : getNamePrefixedWithSchemaName ( primaryTable , primarySchemaName || schemaData . schemaName ) ,
339343 name : name ? `CONSTRAINT ${ wrapInQuotes ( name ) } ` : '' ,
340344 foreignKey : isActivated ? foreignKeysToString ( foreignKey ) : foreignActiveKeysToString ( foreignKey ) ,
341345 primaryKey : isActivated ? foreignKeysToString ( primaryKey ) : foreignActiveKeysToString ( primaryKey ) ,
346+ onDelete : foreignOnDelete ? ` ON DELETE ${ foreignOnDelete } ` : '' ,
347+ onUpdate : foreignOnUpdate ? ` ON UPDATE ${ foreignOnUpdate } ` : '' ,
348+ match : foreignMatch ? ` MATCH ${ foreignMatch } ` : '' ,
342349 } ) ;
343350
344351 return {
@@ -358,6 +365,7 @@ module.exports = (baseProvider, options, app) => {
358365 foreignTableActivated,
359366 foreignSchemaName,
360367 primarySchemaName,
368+ customProperties,
361369 } ,
362370 dbData ,
363371 schemaData ,
@@ -370,12 +378,17 @@ module.exports = (baseProvider, options, app) => {
370378 primaryTableActivated &&
371379 foreignTableActivated ;
372380
381+ const { foreignOnDelete, foreignOnUpdate, foreignMatch } = additionalPropertiesForForeignKey ( customProperties ) ;
382+
373383 const foreignKeyStatement = assignTemplates ( templates . createForeignKey , {
374384 primaryTable : getNamePrefixedWithSchemaName ( primaryTable , primarySchemaName || schemaData . schemaName ) ,
375385 foreignTable : getNamePrefixedWithSchemaName ( foreignTable , foreignSchemaName || schemaData . schemaName ) ,
376386 name : name ? wrapInQuotes ( name ) : '' ,
377387 foreignKey : isActivated ? foreignKeysToString ( foreignKey ) : foreignActiveKeysToString ( foreignKey ) ,
378388 primaryKey : isActivated ? foreignKeysToString ( primaryKey ) : foreignActiveKeysToString ( primaryKey ) ,
389+ onDelete : foreignOnDelete ? ` ON DELETE ${ foreignOnDelete } ` : '' ,
390+ onUpdate : foreignOnUpdate ? ` ON UPDATE ${ foreignOnUpdate } ` : '' ,
391+ match : foreignMatch ? ` MATCH ${ foreignMatch } ` : '' ,
379392 } ) ;
380393
381394 return {
0 commit comments