Skip to content

Commit

Permalink
fix: resolve nameless TableForeign on drop foreign key (#9460)
Browse files Browse the repository at this point in the history
Closes #9432
  • Loading branch information
iJhefe committed Nov 4, 2022
1 parent 2e1c9fd commit efb4168
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/driver/postgres/PostgresQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2874,6 +2874,15 @@ export class PostgresQueryRunner
`Supplied foreign key was not found in table ${table.name}`,
)

if (!foreignKey.name) {
foreignKey.name = this.connection.namingStrategy.foreignKeyName(
table,
foreignKey.columnNames,
this.getTablePath(foreignKey),
foreignKey.referencedColumnNames,
)
}

const up = this.dropForeignKeySql(table, foreignKey)
const down = this.createForeignKeySql(table, foreignKey)
await this.executeQueries(up, down)
Expand Down

0 comments on commit efb4168

Please sign in to comment.