From db628cec11d4d011205f2cc8f1aa7b0f7c2662f5 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 9 Apr 2023 21:48:01 -0500 Subject: [PATCH] fix(server): cannot delete an asset if presented in album (#2223) * fix(server): cannot delete an asset if presented in album * added migration * preserve correct migration --- server/libs/infra/src/entities/album.entity.ts | 2 +- server/libs/infra/src/entities/asset.entity.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/libs/infra/src/entities/album.entity.ts b/server/libs/infra/src/entities/album.entity.ts index a785a939d3..6dcebf8a17 100644 --- a/server/libs/infra/src/entities/album.entity.ts +++ b/server/libs/infra/src/entities/album.entity.ts @@ -43,7 +43,7 @@ export class AlbumEntity { @JoinTable() sharedUsers!: UserEntity[]; - @ManyToMany(() => AssetEntity) + @ManyToMany(() => AssetEntity, (asset) => asset.albums) @JoinTable() assets!: AssetEntity[]; diff --git a/server/libs/infra/src/entities/asset.entity.ts b/server/libs/infra/src/entities/asset.entity.ts index 6c003484e5..ba83e62542 100644 --- a/server/libs/infra/src/entities/asset.entity.ts +++ b/server/libs/infra/src/entities/asset.entity.ts @@ -101,7 +101,7 @@ export class AssetEntity { @JoinTable({ name: 'shared_link__asset' }) sharedLinks!: SharedLinkEntity[]; - @ManyToMany(() => AlbumEntity, (album) => album.assets) + @ManyToMany(() => AlbumEntity, (album) => album.assets, { onDelete: 'CASCADE', onUpdate: 'CASCADE' }) albums?: AlbumEntity[]; }