Bläddra i källkod

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
Alex 2 år sedan
förälder
incheckning
db628cec11

+ 1 - 1
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[];
 

+ 1 - 1
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[];
 }