Skip to content

Commit efb4168

Browse files
authored
fix: resolve nameless TableForeign on drop foreign key (typeorm#9460)
Closes typeorm#9432
1 parent 2e1c9fd commit efb4168

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/driver/postgres/PostgresQueryRunner.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2874,6 +2874,15 @@ export class PostgresQueryRunner
28742874
`Supplied foreign key was not found in table ${table.name}`,
28752875
)
28762876

2877+
if (!foreignKey.name) {
2878+
foreignKey.name = this.connection.namingStrategy.foreignKeyName(
2879+
table,
2880+
foreignKey.columnNames,
2881+
this.getTablePath(foreignKey),
2882+
foreignKey.referencedColumnNames,
2883+
)
2884+
}
2885+
28772886
const up = this.dropForeignKeySql(table, foreignKey)
28782887
const down = this.createForeignKeySql(table, foreignKey)
28792888
await this.executeQueries(up, down)

0 commit comments

Comments
 (0)