bring in config change for migrations

This commit is contained in:
iPromKnight
2024-02-05 15:13:33 +00:00
committed by iPromKnight
parent 3f8fee518e
commit 69fb088b62
2 changed files with 4 additions and 1 deletions

View File

@@ -1,9 +1,12 @@
import {BooleanHelpers} from "../../helpers/boolean_helpers";
export class DatabaseConfig {
public POSTGRES_HOST: string = process.env.POSTGRES_HOST || 'postgres';
public POSTGRES_PORT: number = parseInt(process.env.POSTGRES_PORT || '5432');
public POSTGRES_DB: string = process.env.POSTGRES_DB || 'knightcrawler';
public POSTGRES_USER: string = process.env.POSTGRES_USER || 'postgres';
public POSTGRES_PASSWORD: string = process.env.POSTGRES_PASSWORD || 'postgres';
public AUTO_CREATE_AND_APPLY_MIGRATIONS : boolean = BooleanHelpers.parseBool(process.env.AUTO_CREATE_AND_APPLY_MIGRATIONS, false);
public get POSTGRES_URI() {
return `postgres://${this.POSTGRES_USER}:${this.POSTGRES_PASSWORD}@${this.POSTGRES_HOST}:${this.POSTGRES_PORT}/${this.POSTGRES_DB}`;

View File

@@ -36,7 +36,7 @@ class DatabaseRepository {
try {
await this.database.authenticate();
logger.info('Database connection has been established successfully.');
await this.database.sync({alter: true});
await this.database.sync({alter: configurationService.databaseConfig.AUTO_CREATE_AND_APPLY_MIGRATIONS});
} catch (error) {
logger.error('Failed syncing database: ', error);
throw error;