{"record":{"id":"283374380f475029","repo":"immich-app/immich","slug":"extension-names-extension-extension-is-not-ins","errorCode":null,"errorMessage":"${EXTENSION_NAMES[extension]} extension is not installed","messagePattern":"(.+?) extension is not installed","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/repositories/database.repository.ts","lineNumber":131,"sourceCode":"  async createExtension(extension: DatabaseExtension): Promise<void> {\n    this.logger.log(`Creating ${EXTENSION_NAMES[extension]} extension`);\n    await sql`CREATE EXTENSION IF NOT EXISTS ${sql.raw(extension)} CASCADE`.execute(this.db);\n    if (extension === DatabaseExtension.VectorChord) {\n      const dbName = sql.id(await this.getDatabaseName());\n      await sql`ALTER DATABASE ${dbName} SET vchordrq.probes = 1`.execute(this.db);\n      await sql`SET vchordrq.probes = 1`.execute(this.db);\n    }\n  }\n\n  async dropExtension(extension: DatabaseExtension): Promise<void> {\n    this.logger.log(`Dropping ${EXTENSION_NAMES[extension]} extension`);\n    await sql`DROP EXTENSION IF EXISTS ${sql.raw(extension)}`.execute(this.db);\n  }\n\n  async updateVectorExtension(extension: VectorExtension, targetVersion?: string): Promise<void> {\n    const [{ availableVersion, installedVersion }] = await this.getExtensionVersions([extension]);\n    if (!installedVersion) {\n      throw new Error(`${EXTENSION_NAMES[extension]} extension is not installed`);\n    }\n\n    if (!availableVersion) {\n      throw new Error(`No available version for ${EXTENSION_NAMES[extension]} extension`);\n    }\n    targetVersion ??= availableVersion;\n\n    if (!diff(installedVersion, targetVersion)) {\n      return;\n    }\n\n    await Promise.all([\n      this.db.schema.dropIndex(VectorIndex.Clip).ifExists().execute(),\n      this.db.schema.dropIndex(VectorIndex.Face).ifExists().execute(),\n    ]);\n\n    await sql`ALTER EXTENSION ${sql.raw(extension)} UPDATE TO ${sql.lit(targetVersion)}`.execute(this.db);\n    await Promise.all([this.reindexVectors(VectorIndex.Clip), this.reindexVectors(VectorIndex.Face)]);","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/repositories/database.repository.ts#L113-L149","documentation":"updateVectorExtension upgrades a vector extension to targetVersion, but first checks the currently installed version via getExtensionVersions. If the extension is not installed in this database (installedVersion is empty), it throws instead of silently proceeding. Note this method updates an existing extension; installing a fresh one is a different code path.","triggerScenarios":"Calling updateVectorExtension('vector', ...) when the CREATE EXTENSION for that extension was never run in the connected database, or it was dropped (DROP EXTENSION) beforehand.","commonSituations":"Running migration/upgrade tooling against a fresh database that never had the extension; the extension was dropped during a failed migration; connecting to the wrong database/schema where the extension is absent; hand-running DROP EXTENSION during a manual cleanup.","solutions":["Install the extension first: CREATE EXTENSION IF NOT EXISTS vector; (or 'vectors'/'vchord') then retry the update","Confirm you are connected to the Immich database (check DB_DATABASE_NAME) — the extension may be installed in a different database","Check installed extensions with SELECT extname FROM pg_extension; and use the exact name Immich expects","If the extension was intentionally removed, use the install path (e.g. Immich's createVectorExtension) instead of the update path"],"exampleFix":"-- before running the app/upgrade\nDROP EXTENSION IF EXISTS vector;\n-- after\nCREATE EXTENSION IF NOT EXISTS vector;","handlingStrategy":"validation","validationCode":"const { rows } = await sql`SELECT extname FROM pg_extension WHERE extname IN ('vector','vectors','vchord')`;\nif (!rows.some((r) => r.extname === 'vector')) await sql`CREATE EXTENSION IF NOT EXISTS vector`;","typeGuard":"function isInstalled(versions: { name: string; installedVersion: string | null }[]): boolean {\n  return versions.length > 0 && versions[0].installedVersion != null;\n}","tryCatchPattern":"try {\n  await repo.updateVectorExtension(extension);\n} catch (e) {\n  if ((e as Error).message.endsWith('extension is not installed')) {\n    await sql`CREATE EXTENSION IF NOT EXISTS vector`; // install then retry once\n  } else throw e;\n}","preventionTips":["Run CREATE EXTENSION IF NOT EXISTS as part of initial provisioning","Verify connection targets the correct database before extension operations","Check pg_extension contents in pre-deploy health checks"],"tags":["database","postgres","extension","migration"],"backgroundTag":"missing-dependency","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}