2024-10-03 17:48:40 -04:00
|
|
|
import { ConfigRepository } from 'src/repositories/config.repository';
|
2025-04-29 19:23:01 +01:00
|
|
|
import { vectorIndexQuery } from 'src/utils/database';
|
2023-12-08 11:15:46 -05:00
|
|
|
import { MigrationInterface, QueryRunner } from 'typeorm';
|
|
|
|
|
|
2024-10-03 17:48:40 -04:00
|
|
|
const vectorExtension = new ConfigRepository().getEnv().database.vectorExtension;
|
|
|
|
|
|
2023-12-08 11:15:46 -05:00
|
|
|
export class AddFaceEmbeddingIndex1700714033632 implements MigrationInterface {
|
|
|
|
|
name = 'AddFaceEmbeddingIndex1700714033632';
|
|
|
|
|
|
|
|
|
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
2024-02-06 21:46:38 -05:00
|
|
|
await queryRunner.query(`SET search_path TO "$user", public, vectors`);
|
|
|
|
|
|
2025-04-29 19:23:01 +01:00
|
|
|
await queryRunner.query(vectorIndexQuery({ vectorExtension, table: 'asset_faces', indexName: 'face_index' }));
|
2023-12-08 11:15:46 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
|
|
|
await queryRunner.query(`DROP INDEX IF EXISTS face_index`);
|
|
|
|
|
}
|
|
|
|
|
}
|