mirror of
https://github.com/immich-app/immich.git
synced 2025-05-24 01:12:58 -04:00
handle different db name
This commit is contained in:
parent
db2493d003
commit
e851884f88
@ -116,7 +116,7 @@ export const DummyValue = {
|
||||
DATE: new Date(),
|
||||
TIME_BUCKET: '2024-01-01T00:00:00.000Z',
|
||||
BOOLEAN: true,
|
||||
VECTOR: JSON.stringify(Array.from({ length: 512 }, () => 0)),
|
||||
VECTOR: '[1,2,3]',
|
||||
};
|
||||
|
||||
export const GENERATE_SQL_KEY = 'generate-sql-key';
|
||||
|
@ -222,21 +222,6 @@ where
|
||||
"person"."ownerId" = $3
|
||||
and "asset_faces"."deletedAt" is null
|
||||
|
||||
-- PersonRepository.refreshFaces
|
||||
with
|
||||
"added_embeddings" as (
|
||||
insert into
|
||||
"face_search" ("faceId", "embedding")
|
||||
values
|
||||
($1, $2)
|
||||
)
|
||||
select
|
||||
from
|
||||
(
|
||||
select
|
||||
1
|
||||
) as "dummy"
|
||||
|
||||
-- PersonRepository.getFacesByIds
|
||||
select
|
||||
"asset_faces".*,
|
||||
|
@ -84,7 +84,7 @@ limit
|
||||
$7
|
||||
offset
|
||||
$8
|
||||
commit
|
||||
rollback
|
||||
|
||||
-- SearchRepository.searchDuplicates
|
||||
begin
|
||||
@ -115,7 +115,7 @@ from
|
||||
"cte"
|
||||
where
|
||||
"cte"."distance" <= $7
|
||||
commit
|
||||
rollback
|
||||
|
||||
-- SearchRepository.searchFaces
|
||||
begin
|
||||
@ -144,7 +144,7 @@ from
|
||||
"cte"
|
||||
where
|
||||
"cte"."distance" <= $4
|
||||
commit
|
||||
rollback
|
||||
|
||||
-- SearchRepository.searchPlaces
|
||||
select
|
||||
|
@ -115,9 +115,10 @@ export class DatabaseRepository {
|
||||
async createExtension(extension: DatabaseExtension): Promise<void> {
|
||||
await sql`CREATE EXTENSION IF NOT EXISTS ${sql.raw(extension)} CASCADE`.execute(this.db);
|
||||
if (extension === DatabaseExtension.VECTORCHORD) {
|
||||
await sql`ALTER DATABASE immich SET vchordrq.prewarm_dim = '512,640,768,1024,1152,1536'`.execute(this.db);
|
||||
const db = await this.getDatabaseName();
|
||||
await sql`ALTER DATABASE ${sql.table(db)} SET vchordrq.prewarm_dim = '512,640,768,1024,1152,1536'`.execute(this.db);
|
||||
await sql`SET vchordrq.prewarm_dim = '512,640,768,1024,1152,1536'`.execute(this.db);
|
||||
await sql`ALTER DATABASE immich SET vchordrq.probes = 1`.execute(this.db);
|
||||
await sql`ALTER DATABASE ${sql.table(db)} SET vchordrq.probes = 1`.execute(this.db);
|
||||
await sql`SET vchordrq.probes = 1`.execute(this.db);
|
||||
}
|
||||
}
|
||||
@ -270,6 +271,11 @@ export class DatabaseRepository {
|
||||
await sql`SET search_path TO "$user", public, vectors`.execute(tx);
|
||||
}
|
||||
|
||||
private async getDatabaseName(): Promise<string> {
|
||||
const { rows } = await sql<{ db: string }>`SELECT current_database() as db`.execute(this.db);
|
||||
return rows[0].db;
|
||||
}
|
||||
|
||||
async getDimensionSize(table: string, column = 'embedding'): Promise<number> {
|
||||
const { rows } = await sql<{ dimsize: number }>`
|
||||
SELECT atttypmod as dimsize
|
||||
|
@ -400,7 +400,6 @@ export class PersonRepository {
|
||||
return results.map(({ id }) => id);
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [[], [], [{ faceId: DummyValue.UUID, embedding: DummyValue.VECTOR }]] })
|
||||
async refreshFaces(
|
||||
facesToAdd: (Insertable<AssetFaces> & { assetId: string })[],
|
||||
faceIdsToRemove: string[],
|
||||
|
Loading…
x
Reference in New Issue
Block a user