Jelajahi Sumber

fix(server): add original path and library id index to asset (#4410)

* fix: add original path index

* fix: use libraryId for index, too

* fix: revert openapi change
Jonathan Jogenfors 1 tahun lalu
induk
melakukan
f57acc0802

+ 1 - 0
server/src/infra/entities/asset.entity.ts

@@ -31,6 +31,7 @@ export const ASSET_CHECKSUM_CONSTRAINT = 'UQ_assets_owner_library_checksum';
 })
 })
 @Index('IDX_day_of_month', { synchronize: false })
 @Index('IDX_day_of_month', { synchronize: false })
 @Index('IDX_month', { synchronize: false })
 @Index('IDX_month', { synchronize: false })
+@Index('IDX_originalPath_libraryId', ['originalPath', 'libraryId'])
 // For all assets, each originalpath must be unique per user and library
 // For all assets, each originalpath must be unique per user and library
 export class AssetEntity {
 export class AssetEntity {
   @PrimaryGeneratedColumn('uuid')
   @PrimaryGeneratedColumn('uuid')

+ 13 - 0
server/src/infra/migrations/1696888644031-AddOriginalPathIndex.ts

@@ -0,0 +1,13 @@
+import { MigrationInterface, QueryRunner } from 'typeorm';
+
+export class AddOriginalPathIndex1696888644031 implements MigrationInterface {
+  name = 'AddOriginalPathIndex1696888644031';
+
+  public async up(queryRunner: QueryRunner): Promise<void> {
+    await queryRunner.query(`CREATE INDEX "IDX_originalPath_libraryId" ON "assets" ("originalPath", "libraryId")`);
+  }
+
+  public async down(queryRunner: QueryRunner): Promise<void> {
+    await queryRunner.query(`DROP INDEX "public"."IDX_originalPath_libraryId"`);
+  }
+}