mirror of
https://github.com/immich-app/immich.git
synced 2025-06-23 15:30:51 -04:00
fix(server): drop vector indices before updating extension (#19283)
drop indices before updating
This commit is contained in:
parent
e29103b69f
commit
49ed212af8
@ -142,21 +142,29 @@ export class DatabaseRepository {
|
|||||||
}
|
}
|
||||||
targetVersion ??= availableVersion;
|
targetVersion ??= availableVersion;
|
||||||
|
|
||||||
const isVectors = extension === DatabaseExtension.VECTORS;
|
|
||||||
let restartRequired = false;
|
let restartRequired = false;
|
||||||
const diff = semver.diff(installedVersion, targetVersion);
|
const diff = semver.diff(installedVersion, targetVersion);
|
||||||
|
if (!diff) {
|
||||||
|
return { restartRequired: false };
|
||||||
|
}
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
this.db.schema.dropIndex(VectorIndex.CLIP).ifExists().execute(),
|
||||||
|
this.db.schema.dropIndex(VectorIndex.FACE).ifExists().execute(),
|
||||||
|
]);
|
||||||
|
|
||||||
await this.db.transaction().execute(async (tx) => {
|
await this.db.transaction().execute(async (tx) => {
|
||||||
await this.setSearchPath(tx);
|
await this.setSearchPath(tx);
|
||||||
|
|
||||||
await sql`ALTER EXTENSION ${sql.raw(extension)} UPDATE TO ${sql.lit(targetVersion)}`.execute(tx);
|
await sql`ALTER EXTENSION ${sql.raw(extension)} UPDATE TO ${sql.lit(targetVersion)}`.execute(tx);
|
||||||
|
|
||||||
if (isVectors && (diff === 'major' || diff === 'minor')) {
|
if (extension === DatabaseExtension.VECTORS && (diff === 'major' || diff === 'minor')) {
|
||||||
await sql`SELECT pgvectors_upgrade()`.execute(tx);
|
await sql`SELECT pgvectors_upgrade()`.execute(tx);
|
||||||
restartRequired = true;
|
restartRequired = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (diff && !restartRequired) {
|
if (!restartRequired) {
|
||||||
await Promise.all([this.reindexVectors(VectorIndex.CLIP), this.reindexVectors(VectorIndex.FACE)]);
|
await Promise.all([this.reindexVectors(VectorIndex.CLIP), this.reindexVectors(VectorIndex.FACE)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user