From a35ee9fdf26af0aa35479dbc35f7eb8a65c4cdcd Mon Sep 17 00:00:00 2001 From: Sergey Elpashev Date: Tue, 2 Jan 2024 14:06:20 +0300 Subject: [PATCH] Some db fixes --- .env.example | 2 +- backend/src/modules/settings/settings.service.ts | 6 ++++-- docker-compose.yml | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index a61b666..b25f5c8 100644 --- a/.env.example +++ b/.env.example @@ -1,6 +1,6 @@ DATABASE_PASSWORD=postgres DATABASE_NAME=bot_db -DATABASE_USER=postgres +DATABASE_USERNAME=postgres DATABASE_HOST=localhost DATABASE_PORT=5432 diff --git a/backend/src/modules/settings/settings.service.ts b/backend/src/modules/settings/settings.service.ts index 4353356..bcb744f 100644 --- a/backend/src/modules/settings/settings.service.ts +++ b/backend/src/modules/settings/settings.service.ts @@ -39,8 +39,10 @@ export class SettingsService { editProfile.isActive = data.isActive; if (data.isActive) { const nowActive = await this.botSettingsRepository.findOneBy({ isActive: true }); - nowActive.isActive = false; - await this.botSettingsRepository.save(nowActive); + if (nowActive) { + nowActive.isActive = false; + await this.botSettingsRepository.save(nowActive); + } } } return await this.botSettingsRepository.save(editProfile); diff --git a/docker-compose.yml b/docker-compose.yml index efea673..5fa365f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: container_name: neuro_db image: postgres:alpine environment: - - POSTGRES_USER=${DATABASE_USER} + - POSTGRES_USER=${DATABASE_USERNAME} - POSTGRES_PASSWORD=${DATABASE_PASSWORD} - POSTGRES_DB=${DATABASE_NAME} - PGDATA=/var/lib/postgresql/data/pgdata