mirror of
https://github.com/immich-app/immich.git
synced 2025-01-10 13:56:47 +01:00
56b0643890
* basic changes update version check set ef_search for clip * pgvector compatibility Revert "pgvector compatibility" This reverts commit 2b66a52aa4097dd27da58138c5288fd87cb9b24a. pgvector compatibility: minimal edition pgvector startup check * update extension at startup * wording shortened vector extension variable name * nightly docker * fixed version checks * update tests add tests for updating extension remove unnecessary check * simplify `getRuntimeConfig` * wording * reindex on minor version update * 0.2 upgrade testing update prod compose * acquire lock for init * wip vector down on shutdown * use upgrade helper * update image tag * refine restart check check error message * test reindex testing upstream fix formatting fixed reindexing * use enum in signature * fix tests remove unused code * add reindexing tests * update to official 0.2 remove alpha from version name * add warning test if restart required * update test image to 0.2.0 * linting and test cleanup * formatting * update sql * wording * handle setting search path for new and existing databases * handle new db in reindex check * fix post-update reindexing * get dim size * formatting * use vbase * handle different db name * update sql * linting * fix suggested env
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { DatabaseExtension } from '@app/domain/repositories/database.repository';
|
|
import { DataSource } from 'typeorm';
|
|
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions.js';
|
|
|
|
const url = process.env.DB_URL;
|
|
const urlOrParts = url
|
|
? { url }
|
|
: {
|
|
host: process.env.DB_HOSTNAME || 'localhost',
|
|
port: Number.parseInt(process.env.DB_PORT || '5432'),
|
|
username: process.env.DB_USERNAME || 'postgres',
|
|
password: process.env.DB_PASSWORD || 'postgres',
|
|
database: process.env.DB_DATABASE_NAME || 'immich',
|
|
};
|
|
|
|
/* eslint unicorn/prefer-module: "off" -- We can fix this when migrating to ESM*/
|
|
export const databaseConfig: PostgresConnectionOptions = {
|
|
type: 'postgres',
|
|
entities: [__dirname + '/entities/*.entity.{js,ts}'],
|
|
synchronize: false,
|
|
migrations: [__dirname + '/migrations/*.{js,ts}'],
|
|
subscribers: [__dirname + '/subscribers/*.{js,ts}'],
|
|
migrationsRun: false,
|
|
connectTimeoutMS: 10_000, // 10 seconds
|
|
parseInt8: true,
|
|
...urlOrParts,
|
|
};
|
|
|
|
// this export is used by TypeORM commands in package.json#scripts
|
|
export const dataSource = new DataSource(databaseConfig);
|
|
|
|
export const vectorExt =
|
|
process.env.VECTOR_EXTENSION === 'pgvector' ? DatabaseExtension.VECTOR : DatabaseExtension.VECTORS;
|