mirror of
				https://github.com/KevinMidboe/immich.git
				synced 2025-10-29 17:40:28 +00:00 
			
		
		
		
	chore(server): rename database connection variables (#1437)
This commit is contained in:
		| @@ -1,26 +1,25 @@ | |||||||
| 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; | ||||||
|  | const urlOrParts = url | ||||||
|  |   ? { url } | ||||||
|  |   : { | ||||||
|  |       host: process.env.DB_HOSTNAME || 'immich_postgres', | ||||||
|  |       port: parseInt(process.env.DB_PORT || '5432'), | ||||||
|  |       username: process.env.DB_USERNAME, | ||||||
|  |       password: process.env.DB_PASSWORD, | ||||||
|  |       database: process.env.DB_DATABASE_NAME, | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  | export const databaseConfig: PostgresConnectionOptions = { | ||||||
|   type: 'postgres', |   type: 'postgres', | ||||||
|   entities: [__dirname + '/../**/*.entity.{js,ts}'], |   entities: [__dirname + '/../**/*.entity.{js,ts}'], | ||||||
|   synchronize: false, |   synchronize: false, | ||||||
|   migrations: [__dirname + '/../migrations/*.{js,ts}'], |   migrations: [__dirname + '/../migrations/*.{js,ts}'], | ||||||
|   migrationsRun: true, |   migrationsRun: true, | ||||||
|   connectTimeoutMS: 10000, // 10 seconds |   connectTimeoutMS: 10000, // 10 seconds | ||||||
|  |   ...urlOrParts, | ||||||
| }; | }; | ||||||
|  |  | ||||||
| const envBasedDatabaseConfig = { |  | ||||||
|   host: process.env.DB_HOSTNAME || 'immich_postgres', |  | ||||||
|   port: parseInt(process.env.DB_PORT || '5432'), |  | ||||||
|   username: process.env.DB_USERNAME, |  | ||||||
|   password: process.env.DB_PASSWORD, |  | ||||||
|   database: process.env.DB_DATABASE_NAME, |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| const url = process.env.DB_URL; |  | ||||||
| const additionalSSLDatabaseConfig = url ? { url } : envBasedDatabaseConfig; |  | ||||||
|  |  | ||||||
| export const databaseConfig: PostgresConnectionOptions = { ...baseDatabaseConfig, ...additionalSSLDatabaseConfig }; |  | ||||||
|  |  | ||||||
| export const dataSource = new DataSource(databaseConfig); | export const dataSource = new DataSource(databaseConfig); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user