@@ -408,7 +408,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
408
408
// build new constraint name
409
409
const columnNames = foreignKey . columnNames . map ( column => `\`${ column } \`` ) . join ( ", " ) ;
410
410
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 ) ;
412
412
413
413
// build queries
414
414
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 {
599
599
foreignKey . columnNames . push ( newColumn . name ) ;
600
600
const columnNames = foreignKey . columnNames . map ( column => `\`${ column } \`` ) . join ( ", " ) ;
601
601
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 ) ;
603
603
604
604
// build queries
605
605
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 {
1004
1004
1005
1005
// new FK may be passed without name. In this case we generate FK name manually.
1006
1006
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 ) ;
1008
1008
1009
1009
const up = this . createForeignKeySql ( table , foreignKey ) ;
1010
1010
const down = this . dropForeignKeySql ( table , foreignKey ) ;
@@ -1462,7 +1462,7 @@ export class MysqlQueryRunner extends BaseQueryRunner implements QueryRunner {
1462
1462
const foreignKeysSql = table . foreignKeys . map ( fk => {
1463
1463
const columnNames = fk . columnNames . map ( columnName => `\`${ columnName } \`` ) . join ( ", " ) ;
1464
1464
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 ) ;
1466
1466
const referencedColumnNames = fk . referencedColumnNames . map ( columnName => `\`${ columnName } \`` ) . join ( ", " ) ;
1467
1467
1468
1468
let constraint = `CONSTRAINT \`${ fk . name } \` FOREIGN KEY (${ columnNames } ) REFERENCES ${ this . escapePath ( fk . referencedTableName ) } (${ referencedColumnNames } )` ;
0 commit comments