diff --git a/src/Configuration/ApiServerConfig.cs b/src/Configuration/ApiServerConfig.cs index 308e497..9e51300 100644 --- a/src/Configuration/ApiServerConfig.cs +++ b/src/Configuration/ApiServerConfig.cs @@ -12,7 +12,6 @@ public class ApiServerConfig { public DbProviders ProdDbProvider { get; set; } = DbProviders.MySQL; public string DbPath { get; set; } = string.Empty; public string DbConnection { get; set; } = string.Empty; - public string ProdDbConnection { get; set; } = string.Empty; } public enum DbProviders { diff --git a/src/Model/ProductionDBContext.cs b/src/Model/ProductionDBContext.cs index dec832a..189ff4d 100644 --- a/src/Model/ProductionDBContext.cs +++ b/src/Model/ProductionDBContext.cs @@ -17,14 +17,14 @@ namespace sodoff.Model #if USE_POSTGRESQL if (config.Value.ProdDbProvider == DbProviders.PostgreSQL) { - optionsBuilder.UseNpgsql(config.Value.ProdDbConnection).UseLazyLoadingProxies(); + optionsBuilder.UseNpgsql(Environment.GetEnvironmentVariable("PRODUCTION_DB_CONNECTION")).UseLazyLoadingProxies(); return; } #endif #if USE_MYSQL if (config.Value.ProdDbProvider == DbProviders.MySQL) { - optionsBuilder.UseMySQL(config.Value.ProdDbConnection).UseLazyLoadingProxies(); + optionsBuilder.UseMySQL(Environment.GetEnvironmentVariable("PRODUCTION_DB_CONNECTION")).UseLazyLoadingProxies(); return; } #endif diff --git a/src/appsettings.json b/src/appsettings.json index 84fd08d..dd1b6c0 100644 --- a/src/appsettings.json +++ b/src/appsettings.json @@ -72,10 +72,7 @@ "// DbConnection": "Database connection string for PostgreSQL and MySQL", "// DbConnection PostgreSQL Example": "Host=127.0.0.1;Database=sodoffdb;Username=sodoffuser;Password=secret", "// DbConnection MySQL Example": "Server=127.0.0.1;Database=sodoffdb;Uid=sodoffuser;Pwd=secret;Allow User Variables=True", - "DbConnection": "", - - "// ProdDbConnection": "Database connection string for PostgreSQL and MySQL (examples above)", - "ProdDbConnection": "Server=${PRODUCTION_DB_SERVER};Database=sodoffdb;Uid=sodoffuser;Pwd=${PRODUCTION_DB_PASSWORD};Allow User Variables=True" + "DbConnection": "" }, "Logging": { "LogLevel": {