1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-25 10:43:13 +02:00

fix(server): remove shared link with removed asset (#5845)

This commit is contained in:
martin 2023-12-19 18:05:18 +01:00 committed by GitHub
parent 81af48af7b
commit 7e216809f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -52,7 +52,7 @@ export class SharedLinkEntity {
@Column({ type: 'boolean', default: true }) @Column({ type: 'boolean', default: true })
showExif!: boolean; showExif!: boolean;
@ManyToMany(() => AssetEntity, (asset) => asset.sharedLinks) @ManyToMany(() => AssetEntity, (asset) => asset.sharedLinks, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })
assets!: AssetEntity[]; assets!: AssetEntity[];
@Index('IDX_sharedlink_albumId') @Index('IDX_sharedlink_albumId')

View File

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class FixRemovedAssetsSharedLink1702942303661 implements MigrationInterface {
name = 'FixRemovedAssetsSharedLink1702942303661'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "shared_link__asset" DROP CONSTRAINT "FK_c9fab4aa97ffd1b034f3d6581ab"`);
await queryRunner.query(`ALTER TABLE "shared_link__asset" ADD CONSTRAINT "FK_c9fab4aa97ffd1b034f3d6581ab" FOREIGN KEY ("sharedLinksId") REFERENCES "shared_links"("id") ON DELETE CASCADE ON UPDATE CASCADE`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "shared_link__asset" DROP CONSTRAINT "FK_c9fab4aa97ffd1b034f3d6581ab"`);
await queryRunner.query(`ALTER TABLE "shared_link__asset" ADD CONSTRAINT "FK_c9fab4aa97ffd1b034f3d6581ab" FOREIGN KEY ("sharedLinksId") REFERENCES "shared_links"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
}