From dea9e1ab4013085765aa57bd55d9e1b0dcd93642 Mon Sep 17 00:00:00 2001
From: mertalev <101130780+mertalev@users.noreply.github.com>
Date: Mon, 19 Feb 2024 19:50:29 -0500
Subject: [PATCH 1/2] document vector extension env variable
---
docs/docs/install/environment-variables.md | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/docs/docs/install/environment-variables.md b/docs/docs/install/environment-variables.md
index 09fadbf7073df..4183235f6f3c1 100644
--- a/docs/docs/install/environment-variables.md
+++ b/docs/docs/install/environment-variables.md
@@ -60,14 +60,17 @@ These environment variables are used by the `docker-compose.yml` file and do **N
## Database
-| Variable | Description | Default | Services |
-| :------------ | :---------------- | :---------: | :-------------------- |
-| `DB_URL` | Database URL | | server, microservices |
-| `DB_HOSTNAME` | Database Host | `localhost` | server, microservices |
-| `DB_PORT` | Database Port | `5432` | server, microservices |
-| `DB_USERNAME` | Database User | `postgres` | server, microservices |
-| `DB_PASSWORD` | Database Password | `postgres` | server, microservices |
-| `DB_DATABASE` | Database Name | `immich` | server, microservices |
+| Variable | Description | Default | Services |
+| :------------------------------- | :------------------------------------------------------------ | :----------: | :-------------------- |
+| `DB_URL` | Database URL | | server, microservices |
+| `DB_HOSTNAME` | Database Host | `localhost` | server, microservices |
+| `DB_PORT` | Database Port | `5432` | server, microservices |
+| `DB_USERNAME` | Database User | `postgres` | server, microservices |
+| `DB_PASSWORD` | Database Password | `postgres` | server, microservices |
+| `DB_DATABASE` | Database Name | `immich` | server, microservices |
+| `VECTOR_EXTENSION`\*1 | Database Vector Extension (one of [`pgvector`, `pgvecto.rs`]) | `pgvecto.rs` | server, microservices |
+
+\*1: This setting cannot be changed after the server has successfully started up
:::info
From 95cc0ebec08dad5cb5673fc49b5851fbb0fd77b1 Mon Sep 17 00:00:00 2001
From: mertalev <101130780+mertalev@users.noreply.github.com>
Date: Mon, 19 Feb 2024 19:55:11 -0500
Subject: [PATCH 2/2] change env name
---
docs/docs/install/environment-variables.md | 18 +++++++++---------
server/src/domain/database/database.service.ts | 2 +-
server/src/domain/domain.config.ts | 2 +-
server/src/infra/database.config.ts | 2 +-
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/docs/docs/install/environment-variables.md b/docs/docs/install/environment-variables.md
index 4183235f6f3c1..48d7219d1dd51 100644
--- a/docs/docs/install/environment-variables.md
+++ b/docs/docs/install/environment-variables.md
@@ -60,15 +60,15 @@ These environment variables are used by the `docker-compose.yml` file and do **N
## Database
-| Variable | Description | Default | Services |
-| :------------------------------- | :------------------------------------------------------------ | :----------: | :-------------------- |
-| `DB_URL` | Database URL | | server, microservices |
-| `DB_HOSTNAME` | Database Host | `localhost` | server, microservices |
-| `DB_PORT` | Database Port | `5432` | server, microservices |
-| `DB_USERNAME` | Database User | `postgres` | server, microservices |
-| `DB_PASSWORD` | Database Password | `postgres` | server, microservices |
-| `DB_DATABASE` | Database Name | `immich` | server, microservices |
-| `VECTOR_EXTENSION`\*1 | Database Vector Extension (one of [`pgvector`, `pgvecto.rs`]) | `pgvecto.rs` | server, microservices |
+| Variable | Description | Default | Services |
+| :---------------------------------- | :------------------------------------------------------------ | :----------: | :-------------------- |
+| `DB_URL` | Database URL | | server, microservices |
+| `DB_HOSTNAME` | Database Host | `localhost` | server, microservices |
+| `DB_PORT` | Database Port | `5432` | server, microservices |
+| `DB_USERNAME` | Database User | `postgres` | server, microservices |
+| `DB_PASSWORD` | Database Password | `postgres` | server, microservices |
+| `DB_DATABASE` | Database Name | `immich` | server, microservices |
+| `DB_VECTOR_EXTENSION`\*1 | Database Vector Extension (one of [`pgvector`, `pgvecto.rs`]) | `pgvecto.rs` | server, microservices |
\*1: This setting cannot be changed after the server has successfully started up
diff --git a/server/src/domain/database/database.service.ts b/server/src/domain/database/database.service.ts
index 5ea9e1a474f8d..8cd08acd753f1 100644
--- a/server/src/domain/database/database.service.ts
+++ b/server/src/domain/database/database.service.ts
@@ -72,7 +72,7 @@ export class DatabaseService {
In this case, please run 'CREATE EXTENSION IF NOT EXISTS ${this.vectorExt}' manually as a superuser.
See https://immich.app/docs/guides/database-queries for how to query the database.
- Alternatively, if your Postgres instance has ${extName[otherExt]}, you may use this instead by setting the environment variable 'VECTOR_EXTENSION=${otherExt}'.
+ Alternatively, if your Postgres instance has ${extName[otherExt]}, you may use this instead by setting the environment variable 'DB_VECTOR_EXTENSION=${otherExt}'.
Note that switching between the two extensions after a successful startup is not supported.
The exception is if your version of Immich prior to upgrading was 1.90.2 or earlier.
In this case, you may set either extension now, but you will not be able to switch to the other extension following a successful startup.
diff --git a/server/src/domain/domain.config.ts b/server/src/domain/domain.config.ts
index ed1283ec2fca0..b77fd741264a6 100644
--- a/server/src/domain/domain.config.ts
+++ b/server/src/domain/domain.config.ts
@@ -18,12 +18,12 @@ export const immichAppConfig: ConfigModuleOptions = {
DB_PASSWORD: WHEN_DB_URL_SET,
DB_DATABASE_NAME: WHEN_DB_URL_SET,
DB_URL: Joi.string().optional(),
+ DB_VECTOR_EXTENSION: Joi.string().optional().valid('pgvector', 'pgvecto.rs').default('pgvecto.rs'),
LOG_LEVEL: Joi.string()
.optional()
.valid(...Object.values(LogLevel)),
MACHINE_LEARNING_PORT: Joi.number().optional(),
MICROSERVICES_PORT: Joi.number().optional(),
SERVER_PORT: Joi.number().optional(),
- VECTOR_EXTENSION: Joi.string().optional().valid('pgvector', 'pgvecto.rs').default('pgvecto.rs'),
}),
};
diff --git a/server/src/infra/database.config.ts b/server/src/infra/database.config.ts
index 93926e51cf24c..773e79f8a0812 100644
--- a/server/src/infra/database.config.ts
+++ b/server/src/infra/database.config.ts
@@ -30,4 +30,4 @@ export const databaseConfig: PostgresConnectionOptions = {
export const dataSource = new DataSource(databaseConfig);
export const vectorExt =
- process.env.VECTOR_EXTENSION === 'pgvector' ? DatabaseExtension.VECTOR : DatabaseExtension.VECTORS;
+ process.env.DB_VECTOR_EXTENSION === 'pgvector' ? DatabaseExtension.VECTOR : DatabaseExtension.VECTORS;