aboutsummaryrefslogtreecommitdiff
path: root/BackEnd/Timeline
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-02-12 22:32:10 +0800
committercrupest <crupest@outlook.com>2021-02-12 22:32:10 +0800
commit83910122bfd0aa9bd207b6d5f631774415312716 (patch)
tree7d7fe2cb488c6cdf6fc45d1eb9281d51c31cf7ac /BackEnd/Timeline
parente74195ae38450b54b5e5f376796d78e6da4fc1ae (diff)
downloadtimeline-83910122bfd0aa9bd207b6d5f631774415312716.tar.gz
timeline-83910122bfd0aa9bd207b6d5f631774415312716.tar.bz2
timeline-83910122bfd0aa9bd207b6d5f631774415312716.zip
fix: Fix migration bug.
Diffstat (limited to 'BackEnd/Timeline')
-rw-r--r--BackEnd/Timeline/Program.cs14
-rw-r--r--BackEnd/Timeline/Properties/launchSettings.json5
-rw-r--r--BackEnd/Timeline/Services/Migration/CustomMigrationManager.cs4
3 files changed, 11 insertions, 12 deletions
diff --git a/BackEnd/Timeline/Program.cs b/BackEnd/Timeline/Program.cs
index 0f75908f..19fa6e37 100644
--- a/BackEnd/Timeline/Program.cs
+++ b/BackEnd/Timeline/Program.cs
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Resources;
+using System.Threading.Tasks;
using Timeline.Entities;
using Timeline.Services;
using Timeline.Services.Migration;
@@ -14,20 +15,19 @@ namespace Timeline
{
public static class Program
{
- public static void Main(string[] args)
+ public async static Task Main(string[] args)
{
var host = CreateWebHostBuilder(args).Build();
+ var databaseBackupService = host.Services.GetRequiredService<IDatabaseBackupService>();
+ databaseBackupService.BackupNow();
+
using (var scope = host.Services.CreateScope())
{
- var databaseBackupService = scope.ServiceProvider.GetRequiredService<IDatabaseBackupService>();
- databaseBackupService.BackupNow();
-
var databaseContext = scope.ServiceProvider.GetRequiredService<DatabaseContext>();
- databaseContext.Database.Migrate();
-
+ await databaseContext.Database.MigrateAsync();
var customMigrationManager = scope.ServiceProvider.GetRequiredService<ICustomMigrationManager>();
- customMigrationManager.Migrate();
+ await customMigrationManager.Migrate();
}
host.Run();
diff --git a/BackEnd/Timeline/Properties/launchSettings.json b/BackEnd/Timeline/Properties/launchSettings.json
index 851fc6a8..3c8a465b 100644
--- a/BackEnd/Timeline/Properties/launchSettings.json
+++ b/BackEnd/Timeline/Properties/launchSettings.json
@@ -5,8 +5,7 @@
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_FRONTEND": "Proxy"
- },
- "applicationUrl": "http://0.0.0.0:5000"
+ }
},
"Dev-Mock": {
"commandName": "Project",
@@ -30,4 +29,4 @@
}
}
}
-} \ No newline at end of file
+}
diff --git a/BackEnd/Timeline/Services/Migration/CustomMigrationManager.cs b/BackEnd/Timeline/Services/Migration/CustomMigrationManager.cs
index ba86e10b..f6f156cc 100644
--- a/BackEnd/Timeline/Services/Migration/CustomMigrationManager.cs
+++ b/BackEnd/Timeline/Services/Migration/CustomMigrationManager.cs
@@ -36,7 +36,7 @@ namespace Timeline.Services.Migration
if (!did)
{
- _logger.LogInformation("Begin custom migration '{0}'.", name);
+ _logger.LogWarning("Begin custom migration '{0}'.", name);
await using var transaction = await _database.Database.BeginTransactionAsync();
@@ -47,7 +47,7 @@ namespace Timeline.Services.Migration
await transaction.CommitAsync();
- _logger.LogInformation("End custom migration '{0}'.", name);
+ _logger.LogWarning("End custom migration '{0}'.", name);
}
}
}