mirror of
https://github.com/immich-app/immich.git
synced 2025-01-22 11:42:46 +01:00
1df7be8436
* refactor(server): version * test: better version and log checks
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
export enum DatabaseExtension {
|
|
CUBE = 'cube',
|
|
EARTH_DISTANCE = 'earthdistance',
|
|
VECTOR = 'vector',
|
|
VECTORS = 'vectors',
|
|
}
|
|
|
|
export type VectorExtension = DatabaseExtension.VECTOR | DatabaseExtension.VECTORS;
|
|
|
|
export enum VectorIndex {
|
|
CLIP = 'clip_index',
|
|
FACE = 'face_index',
|
|
}
|
|
|
|
export enum DatabaseLock {
|
|
GeodataImport = 100,
|
|
Migrations = 200,
|
|
StorageTemplateMigration = 420,
|
|
CLIPDimSize = 512,
|
|
LibraryWatch = 1337,
|
|
GetSystemConfig = 69,
|
|
}
|
|
|
|
export const EXTENSION_NAMES: Record<DatabaseExtension, string> = {
|
|
cube: 'cube',
|
|
earthdistance: 'earthdistance',
|
|
vector: 'pgvector',
|
|
vectors: 'pgvecto.rs',
|
|
} as const;
|
|
|
|
export interface VectorUpdateResult {
|
|
restartRequired: boolean;
|
|
}
|
|
|
|
export const IDatabaseRepository = 'IDatabaseRepository';
|
|
|
|
export interface IDatabaseRepository {
|
|
getExtensionVersion(extensionName: string): Promise<string | undefined>;
|
|
getAvailableExtensionVersion(extension: DatabaseExtension): Promise<string | undefined>;
|
|
getPostgresVersion(): Promise<string>;
|
|
createExtension(extension: DatabaseExtension): Promise<void>;
|
|
updateExtension(extension: DatabaseExtension, version?: string): Promise<void>;
|
|
updateVectorExtension(extension: VectorExtension, version?: string): Promise<VectorUpdateResult>;
|
|
reindex(index: VectorIndex): Promise<void>;
|
|
shouldReindex(name: VectorIndex): Promise<boolean>;
|
|
runMigrations(options?: { transaction?: 'all' | 'none' | 'each' }): Promise<void>;
|
|
withLock<R>(lock: DatabaseLock, callback: () => Promise<R>): Promise<R>;
|
|
tryLock(lock: DatabaseLock): Promise<boolean>;
|
|
isBusy(lock: DatabaseLock): boolean;
|
|
wait(lock: DatabaseLock): Promise<void>;
|
|
}
|