1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-07 20:36:48 +01:00

chore(server): rename database connection variables (#1437)

This commit is contained in:
Jason Rasmussen 2023-01-26 21:52:13 -05:00 committed by GitHub
parent 89aff7764d
commit 55d883925f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,16 +1,10 @@
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions'; import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
import { DataSource } from 'typeorm'; import { DataSource } from 'typeorm';
const baseDatabaseConfig: PostgresConnectionOptions = { const url = process.env.DB_URL;
type: 'postgres', const urlOrParts = url
entities: [__dirname + '/../**/*.entity.{js,ts}'], ? { url }
synchronize: false, : {
migrations: [__dirname + '/../migrations/*.{js,ts}'],
migrationsRun: true,
connectTimeoutMS: 10000, // 10 seconds
};
const envBasedDatabaseConfig = {
host: process.env.DB_HOSTNAME || 'immich_postgres', host: process.env.DB_HOSTNAME || 'immich_postgres',
port: parseInt(process.env.DB_PORT || '5432'), port: parseInt(process.env.DB_PORT || '5432'),
username: process.env.DB_USERNAME, username: process.env.DB_USERNAME,
@ -18,9 +12,14 @@ const envBasedDatabaseConfig = {
database: process.env.DB_DATABASE_NAME, database: process.env.DB_DATABASE_NAME,
}; };
const url = process.env.DB_URL; export const databaseConfig: PostgresConnectionOptions = {
const additionalSSLDatabaseConfig = url ? { url } : envBasedDatabaseConfig; type: 'postgres',
entities: [__dirname + '/../**/*.entity.{js,ts}'],
export const databaseConfig: PostgresConnectionOptions = { ...baseDatabaseConfig, ...additionalSSLDatabaseConfig }; synchronize: false,
migrations: [__dirname + '/../migrations/*.{js,ts}'],
migrationsRun: true,
connectTimeoutMS: 10000, // 10 seconds
...urlOrParts,
};
export const dataSource = new DataSource(databaseConfig); export const dataSource = new DataSource(databaseConfig);