mirror of
https://github.com/immich-app/immich.git
synced 2025-12-27 17:24:58 +03:00
chore(server): startup check for pgvecto.rs (#5815)
* startup check for pgvecto.rs * prefilter after assertion * formatting * add assert to migration * more specific import * use runner
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import { getCLIPModelInfo } from '@app/domain/smart-info/smart-info.constant';
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
import { assertVectors } from '../database.config';
|
||||
|
||||
export class UsePgVectors1700713871511 implements MigrationInterface {
|
||||
name = 'UsePgVectors1700713871511';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await assertVectors(queryRunner);
|
||||
|
||||
const faceDimQuery = await queryRunner.query(`
|
||||
SELECT CARDINALITY(embedding::real[]) as dimsize
|
||||
FROM asset_faces
|
||||
@@ -15,8 +18,6 @@ export class UsePgVectors1700713871511 implements MigrationInterface {
|
||||
const clipModelName: string = clipModelNameQuery?.[0]?.['value'] ?? 'ViT-B-32__openai';
|
||||
const clipDimSize = getCLIPModelInfo(clipModelName.replace(/"/g, '')).dimSize;
|
||||
|
||||
await queryRunner.query('CREATE EXTENSION IF NOT EXISTS vectors');
|
||||
|
||||
await queryRunner.query(`
|
||||
ALTER TABLE asset_faces
|
||||
ALTER COLUMN embedding SET NOT NULL,
|
||||
|
||||
Reference in New Issue
Block a user