ToolJet/server/migrations/1664535394458-addForeignKeyForCommentUsers.ts
Midhun G S b0e6a34f18
[Fix] Delete app not working if any user mentioned in comments (#4161)
* Fix for app delete issue

* fix

* fix

* added dbTransactionWrap for more functions

* reuse dbTransactionWrap

* onboarding changes

* SSO fix

* fix

* added test cases

* changed threads comments relation

* added test cases
2022-10-17 23:04:06 +05:30

21 lines
780 B
TypeScript

import { MigrationInterface, QueryRunner, TableForeignKey } from 'typeorm';
export class addForeignKeyForCommentUsers1664535394458 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable('comment_users');
const foreignKey = table.foreignKeys.find((fk) => fk.columnNames.indexOf('comment_id') !== -1);
await queryRunner.dropForeignKey('comment_users', foreignKey);
await queryRunner.createForeignKey(
'comment_users',
new TableForeignKey({
columnNames: ['comment_id'],
referencedColumnNames: ['id'],
referencedTableName: 'comments',
onDelete: 'CASCADE',
})
);
}
public async down(queryRunner: QueryRunner): Promise<void> {}
}