mirror of
https://github.com/immich-app/immich.git
synced 2025-12-16 07:23:44 +09:00
* run migrations after checks * optional migrations * only run checks in server and e2e * re-add migrations for microservices * refactor * move e2e init * remove assert from migration * update providers * update microservices app service * fixed logging * refactored version check, added unit tests * more version tests * don't use mocks for sut * refactor tests * suggest image only if postgres is 14, 15 or 16 * review suggestions * fixed regexp escape * fix typing * update migration
28 lines
964 B
TypeScript
28 lines
964 B
TypeScript
import { DataSource } from 'typeorm';
|
|
import { PostgresConnectionOptions } from 'typeorm/driver/postgres/PostgresConnectionOptions';
|
|
|
|
const url = process.env.DB_URL;
|
|
const urlOrParts = url
|
|
? { url }
|
|
: {
|
|
host: process.env.DB_HOSTNAME || 'localhost',
|
|
port: 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',
|
|
};
|
|
|
|
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: 10000, // 10 seconds
|
|
...urlOrParts,
|
|
};
|
|
|
|
// this export is used by TypeORM commands in package.json#scripts
|
|
export const dataSource = new DataSource(databaseConfig);
|