diff options
Diffstat (limited to 'BackEnd/Timeline/Services/DatabaseManagement')
-rw-r--r-- | BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs index c3d9ac4e..a4814069 100644 --- a/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs +++ b/BackEnd/Timeline/Services/DatabaseManagement/DatabaseManagementService.cs @@ -1,9 +1,11 @@ using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Threading;
using System.Threading.Tasks;
+using Timeline.Configs;
using Timeline.Entities;
namespace Timeline.Services.DatabaseManagement
@@ -11,10 +13,12 @@ namespace Timeline.Services.DatabaseManagement public class DatabaseManagementService : IHostedService
{
private readonly IServiceProvider _serviceProvider;
+ private readonly bool _disableAutoBackup;
- public DatabaseManagementService(IServiceProvider serviceProvider)
+ public DatabaseManagementService(IServiceProvider serviceProvider, IConfiguration configuration)
{
_serviceProvider = serviceProvider;
+ _disableAutoBackup = ApplicationConfiguration.GetBoolConfig(configuration, ApplicationConfiguration.DisableAutoBackupKey, false);
}
public async Task StartAsync(CancellationToken cancellationToken = default)
@@ -27,7 +31,10 @@ namespace Timeline.Services.DatabaseManagement var customMigrator = provider.GetRequiredService<IDatabaseCustomMigrator>();
- await backupService.BackupAsync(cancellationToken);
+ if (!_disableAutoBackup)
+ {
+ await backupService.BackupAsync(cancellationToken);
+ }
await database.Database.MigrateAsync(cancellationToken);
await customMigrator.MigrateAsync(cancellationToken);
}
|