@@ -408,7 +408,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
408408 // build new constraint name
409409 const columnNames = foreignKey . columnNames . map ( column => `\`${ column } \`` ) . join ( ", " ) ;
410410 const referencedColumnNames = foreignKey . referencedColumnNames . map ( column => `\`${ column } \`` ) . join ( "," ) ;
411- const newForeignKeyName = this . connection . namingStrategy . foreignKeyName ( newTable , foreignKey . columnNames ) ;
411+ const newForeignKeyName = this . connection . namingStrategy . foreignKeyName ( newTable , foreignKey . columnNames , foreignKey . referencedTableName , foreignKey . referencedColumnNames ) ;
412412
413413 // build queries
414414 let up = `ALTER TABLE ${ this . escapePath ( newTable ) } DROP FOREIGN KEY \`${ foreignKey . name } \`, ADD CONSTRAINT \`${ newForeignKeyName } \` FOREIGN KEY (${ columnNames } ) ` +
@@ -599,7 +599,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
599599 foreignKey . columnNames . push ( newColumn . name ) ;
600600 const columnNames = foreignKey . columnNames . map ( column => `\`${ column } \`` ) . join ( ", " ) ;
601601 const referencedColumnNames = foreignKey . referencedColumnNames . map ( column => `\`${ column } \`` ) . join ( "," ) ;
602- const newForeignKeyName = this . connection . namingStrategy . foreignKeyName ( clonedTable , foreignKey . columnNames ) ;
602+ const newForeignKeyName = this . connection . namingStrategy . foreignKeyName ( clonedTable , foreignKey . columnNames , foreignKey . referencedTableName , foreignKey . referencedColumnNames ) ;
603603
604604 // build queries
605605 let up = `ALTER TABLE ${ this . escapePath ( table ) } DROP FOREIGN KEY \`${ foreignKey . name } \`, ADD CONSTRAINT \`${ newForeignKeyName } \` FOREIGN KEY (${ columnNames } ) ` +
@@ -1004,7 +1004,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
10041004
10051005 // new FK may be passed without name. In this case we generate FK name manually.
10061006 if ( ! foreignKey . name )
1007- foreignKey . name = this . connection . namingStrategy . foreignKeyName ( table . name , foreignKey . columnNames ) ;
1007+ foreignKey . name = this . connection . namingStrategy . foreignKeyName ( table . name , foreignKey . columnNames , foreignKey . referencedTableName , foreignKey . referencedColumnNames ) ;
10081008
10091009 const up = this . createForeignKeySql ( table , foreignKey ) ;
10101010 const down = this . dropForeignKeySql ( table , foreignKey ) ;
@@ -1462,7 +1462,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
14621462 const foreignKeysSql = table . foreignKeys . map ( fk => {
14631463 const columnNames = fk . columnNames . map ( columnName => `\`${ columnName } \`` ) . join ( ", " ) ;
14641464 if ( ! fk . name )
1465- fk . name = this . connection . namingStrategy . foreignKeyName ( table . name , fk . columnNames ) ;
1465+ fk . name = this . connection . namingStrategy . foreignKeyName ( table . name , fk . columnNames , fk . referencedTableName , fk . referencedColumnNames ) ;
14661466 const referencedColumnNames = fk . referencedColumnNames . map ( columnName => `\`${ columnName } \`` ) . join ( ", " ) ;
14671467
14681468 let constraint = `CONSTRAINT \`${ fk . name } \` FOREIGN KEY (${ columnNames } ) REFERENCES ${ this . escapePath ( fk . referencedTableName ) } (${ referencedColumnNames } )` ;
0 commit comments