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