Repository navigation
Closed
Labels
Description
Issue Description
When drop a FK what name was generated by TypeORM (without a name in TableForeignKey) the query generated by dropForeignKey is setting the FK name as 'undefined'
Expected Behavior
Generate FK name like method createForeignKey
ALTER TABLE "some_table" DROP CONSTRAINT "FK_436590330fb0eee0a7fa10dc49b"
Actual Behavior
Generate 'undefined' FK name
ALTER TABLE "some_table" DROP CONSTRAINT "undefined"
Steps to Reproduce
- Create a migration what should create a table FK using
TableForeignKey - Run the migration
- Revert it
export class someMigration1664970153005 implements MigrationInterface {
private readonly table = 'some_table';
private readonly column = new TableColumn({
name: 'column_name',
type: 'int',
});
private readonly foreignKey = new TableForeignKey({
columnNames: [this.column.name],
referencedColumnNames: ['id'],
referencedTableName: this.table,
});
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createForeignKey(this.table, this.foreignKey);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropForeignKey(this.table, this.foreignKey);
}
}My Environment
| Dependency | Version |
|---|---|
| Operating System | Win 10 |
| Node.js version | 16.14.2 |
| Typescript version | 4.7.4 |
| TypeORM version | 0.3.9 |
Additional Context
I've tested only in a Postgres DB, others DB Type can has the same issue
Relevant Database Driver(s)
| DB Type | Reproducible |
|---|---|
aurora-mysql |
no |
aurora-postgres |
no |
better-sqlite3 |
no |
cockroachdb |
no |
cordova |
no |
expo |
no |
mongodb |
no |
mysql |
no |
nativescript |
no |
oracle |
no |
postgres |
yes |
react-native |
no |
sap |
no |
spanner |
no |
sqlite |
no |
sqlite-abstract |
no |
sqljs |
no |
sqlserver |
no |
Are you willing to resolve this issue by submitting a Pull Request?
- ✅ Yes, I have the time, and I know how to start.
- ✖️ Yes, I have the time, but I don't know how to start. I would need guidance.
- ✖️ No, I don’t have the time, but I can support (using donations) development.
- ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Activity
KiranPatil30 commentedon Oct 8, 2022
Hello Sir , Can You Assign This Issue to Me?
fix: resolve nameless TableForeign on drop foreign key
fix: resolve nameless TableForeign on drop foreign key (#9460)