High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(server): remove shared link with removed asset (#5845)
martin7e216809f3c7
diff --git a/server/src/infra/entities/shared-link.entity.ts b/server/src/infra/entities/shared-link.entity.tsindex 1e42b8d2c2..f64ad84249 100644--- a/server/src/infra/entities/shared-link.entity.ts+++ b/server/src/infra/entities/shared-link.entity.ts@@ -52,7 +52,7 @@ export class SharedLinkEntity {@Column({ type: 'boolean', default: true })showExif!: boolean;- @ManyToMany(() => AssetEntity, (asset) => asset.sharedLinks)+ @ManyToMany(() => AssetEntity, (asset) => asset.sharedLinks, { onDelete: 'CASCADE', onUpdate: 'CASCADE' })assets!: AssetEntity[];@Index('IDX_sharedlink_albumId')diff --git a/server/src/infra/migrations/1702942303661-FixRemovedAssetsSharedLink.ts b/server/src/infra/migrations/1702942303661-FixRemovedAssetsSharedLink.tsnew file mode 100644index 0000000000..a55b12fa74--- /dev/null+++ b/server/src/infra/migrations/1702942303661-FixRemovedAssetsSharedLink.ts@@ -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`);+ }++}