zappyzep/backend/src/migrations/1596994103885-AddCaseNotesForeignKey.ts
2020-08-09 22:44:46 +03:00

22 lines
713 B
TypeScript

import { MigrationInterface, QueryRunner } from "typeorm";
import { TableForeignKey } from "typeorm/index";
export class AddCaseNotesForeignKey1596994103885 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<any> {
await queryRunner.createForeignKey(
"case_notes",
new TableForeignKey({
name: "case_notes_case_id_fk",
columnNames: ["case_id"],
referencedTableName: "cases",
referencedColumnNames: ["id"],
onDelete: "CASCADE",
onUpdate: "CASCADE",
}),
);
}
public async down(queryRunner: QueryRunner): Promise<any> {
await queryRunner.dropForeignKey("case_notes", "case_notes_case_id_fk");
}
}