moderation_logテーブルのUserテーブルへのFK制約をon delete set null に変更する

This commit is contained in:
Camilla Ett 2024-04-07 15:19:03 +09:00
parent 2f8fb105a5
commit 900f27e482
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,20 @@
/*
* SPDX-FileCopyrightText: syuilo and misskey-project
* SPDX-License-Identifier: AGPL-3.0-only
*/
export class ModerationLogDoNotCascadeOnDelete1712469608832 {
name = 'ModerationLogDoNotCascadeOnDelete1712469608832'
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "moderation_log" DROP CONSTRAINT "FK_a08ad074601d204e0f69da9a954"`)
await queryRunner.query(`ALTER TABLE "moderation_log" ADD CONSTRAINT "FK_a08ad074601d204e0f69da9a954" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE SET NULL ON UPDATE NO ACTION`);
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "moderation_log" DROP CONSTRAINT "FK_a08ad074601d204e0f69da9a954"`)
await queryRunner.query(`ALTER TABLE "moderation_log" ADD CONSTRAINT "FK_a08ad074601d204e0f69da9a954" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
}
}

View File

@ -17,7 +17,7 @@ export class MiModerationLog {
public userId: MiUser['id'];
@ManyToOne(type => MiUser, {
onDelete: 'CASCADE',
onDelete: 'SET NULL',
})
@JoinColumn()
public user: MiUser | null;