From bc06863d287c857e8b4584c0ebdf32f7f6016b0d Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Thu, 24 Oct 2024 16:45:00 -0400 Subject: [PATCH] feat: track when assets are added to an album (#13725) --- server/src/entities/album.entity.ts | 2 +- .../1729793521993-AddAlbumAssetCreatedAt.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 server/src/migrations/1729793521993-AddAlbumAssetCreatedAt.ts diff --git a/server/src/entities/album.entity.ts b/server/src/entities/album.entity.ts index e5d2c98814..5aec5a0f47 100644 --- a/server/src/entities/album.entity.ts +++ b/server/src/entities/album.entity.ts @@ -52,7 +52,7 @@ export class AlbumEntity { albumUsers!: AlbumUserEntity[]; @ManyToMany(() => AssetEntity, (asset) => asset.albums) - @JoinTable() + @JoinTable({ synchronize: false }) assets!: AssetEntity[]; @OneToMany(() => SharedLinkEntity, (link) => link.album) diff --git a/server/src/migrations/1729793521993-AddAlbumAssetCreatedAt.ts b/server/src/migrations/1729793521993-AddAlbumAssetCreatedAt.ts new file mode 100644 index 0000000000..280b34890d --- /dev/null +++ b/server/src/migrations/1729793521993-AddAlbumAssetCreatedAt.ts @@ -0,0 +1,13 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class AddAlbumAssetCreatedAt1729793521993 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "albums_assets_assets" ADD COLUMN "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now()`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "albums_assets_assets" DROP COLUMN "createdAt"`); + } +}