Merge branch 'develop' into milestone/ff-admin-unit
# Conflicts: # src/data-source.ts
This commit is contained in:
commit
799a719012
6 changed files with 57 additions and 7 deletions
|
@ -0,0 +1,44 @@
|
|||
import { MigrationInterface, QueryRunner, TableForeignKey } from "typeorm";
|
||||
import { newsletter_table } from "./baseSchemaTables/newsletter";
|
||||
|
||||
export class UpdateNewsletterQueryRelation1752502069178 implements MigrationInterface {
|
||||
name = "UpdateNewsletterQueryRelation1752502069178";
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
const table = await queryRunner.getTable("newsletter");
|
||||
const foreignKey = table?.foreignKeys.find((fk) => fk.columnNames.includes("recipientsByQueryId"));
|
||||
if (foreignKey) {
|
||||
await queryRunner.dropForeignKey("newsletter", foreignKey);
|
||||
}
|
||||
|
||||
await queryRunner.createForeignKey(
|
||||
newsletter_table,
|
||||
new TableForeignKey({
|
||||
columnNames: ["recipientsByQueryId"],
|
||||
referencedColumnNames: ["id"],
|
||||
referencedTableName: "query",
|
||||
onDelete: "SET NULL",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
const table = await queryRunner.getTable("newsletter");
|
||||
const foreignKey = table?.foreignKeys.find((fk) => fk.columnNames.includes("recipientsByQueryId"));
|
||||
if (foreignKey) {
|
||||
await queryRunner.dropForeignKey("newsletter", foreignKey);
|
||||
}
|
||||
|
||||
await queryRunner.createForeignKey(
|
||||
newsletter_table,
|
||||
new TableForeignKey({
|
||||
columnNames: ["recipientsByQueryId"],
|
||||
referencedColumnNames: ["id"],
|
||||
referencedTableName: "query",
|
||||
onDelete: "CASCADE",
|
||||
onUpdate: "RESTRICT",
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue