diff options
Diffstat (limited to 'backend/Elements.Backend/Program.cs')
| -rw-r--r-- | backend/Elements.Backend/Program.cs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/backend/Elements.Backend/Program.cs b/backend/Elements.Backend/Program.cs index f7b9b4b..6804d1a 100644 --- a/backend/Elements.Backend/Program.cs +++ b/backend/Elements.Backend/Program.cs @@ -14,13 +14,11 @@ builder.Services.AddControllers().AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});
-if (builder.Environment.IsDevelopment())
+builder.Services.AddDbContext<ApplicationDbContext>(options =>
{
- builder.Services.AddDbContext<ApplicationDbContext>(options =>
- {
- options.UseSqlite("Data Source=elements.db");
- });
-}
+ options.UseNpgsql(Environment.GetEnvironmentVariable("ELEM_DB_CONN_STR") ??
+ "Server=database;Port=5432;Database=elements;User Id=elements;Password=elementspass");
+});
builder.Services
.AddAuthentication(options =>
@@ -52,6 +50,12 @@ builder.Services.AddHostedService( var app = builder.Build();
+using (var scope = app.Services.CreateScope())
+{
+ ApplicationDbContext context = scope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
+ context.Database.Migrate();
+}
+
app.UseHttpsRedirection();
app.UseAuthentication();
|
