change: relation of newsletter receivers to query
This commit is contained in:
parent
013cb9f95d
commit
399c4d84a1
3 changed files with 51 additions and 2 deletions
|
@ -50,6 +50,7 @@ import { memberEducations } from "./entity/club/member/memberEducations";
|
|||
|
||||
import { BackupAndResetDatabase1749296262915 } from "./migrations/1749296262915-BackupAndResetDatabase";
|
||||
import { CreateSchema1749296280721 } from "./migrations/1749296280721-CreateSchema";
|
||||
import { UpdateNewsletterQueryRelation1752502069178 } from "./migrations/1752502069178-updateNewsletterQueryRelation";
|
||||
|
||||
configCheck();
|
||||
|
||||
|
@ -108,7 +109,11 @@ const dataSource = new DataSource({
|
|||
webapiPermission,
|
||||
setting,
|
||||
],
|
||||
migrations: [BackupAndResetDatabase1749296262915, CreateSchema1749296280721],
|
||||
migrations: [
|
||||
BackupAndResetDatabase1749296262915,
|
||||
CreateSchema1749296280721,
|
||||
UpdateNewsletterQueryRelation1752502069178,
|
||||
],
|
||||
migrationsRun: true,
|
||||
migrationsTransactionMode: "each",
|
||||
subscribers: [],
|
||||
|
|
|
@ -40,7 +40,7 @@ export class newsletter {
|
|||
|
||||
@ManyToOne(() => query, {
|
||||
nullable: true,
|
||||
onDelete: "CASCADE",
|
||||
onDelete: "SET NULL",
|
||||
onUpdate: "RESTRICT",
|
||||
cascade: ["insert"],
|
||||
})
|
||||
|
|
|
@ -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