From cc23244c0fdbdc91e2c28309b7b9ef796ae638cc Mon Sep 17 00:00:00 2001 From: Michael Schramm Date: Sun, 2 May 2021 18:33:18 +0200 Subject: [PATCH] fix sqlite base definition --- src/app.imports.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/app.imports.ts b/src/app.imports.ts index a468074..c5e98a0 100644 --- a/src/app.imports.ts +++ b/src/app.imports.ts @@ -105,11 +105,15 @@ export const imports = [ TypeOrmModule.forRootAsync({ imports: [ConfigModule], inject: [ConfigService], - useFactory: (configService: ConfigService): TypeOrmModuleOptions => ({ + useFactory: (configService: ConfigService): TypeOrmModuleOptions => { + const type: any = configService.get('DATABASE_DRIVER', 'sqlite') + + return ({ name: 'ohmyform', synchronize: false, - type: configService.get('DATABASE_DRIVER', 'sqlite') as any, - url: configService.get('DATABASE_URL', 'sqlite://data.sqlite'), + type, + url: configService.get('DATABASE_URL'), + database: type === 'sqlite' ? configService.get('DATABASE_URL', 'data.sqlite').replace('sqlite://', '') : undefined, ssl: configService.get('DATABASE_SSL', 'false') === 'true' ? { rejectUnauthorized: false } : false, entityPrefix: configService.get('DATABASE_TABLE_PREFIX', ''), logging: configService.get('DATABASE_LOGGING', 'false') === 'true', @@ -118,7 +122,8 @@ export const imports = [ `${__dirname}/**/migrations/**/*{.ts,.js}`, ], migrationsRun: configService.get('DATABASE_MIGRATE', true), - }), + }) + }, }), TypeOrmModule.forFeature(entities), MailerModule.forRootAsync({