diff options
author | crupest <crupest@outlook.com> | 2021-02-12 22:32:10 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-02-12 22:32:10 +0800 |
commit | 5849d34d9fcf1ccfb7fe5cc0842765129f7198b4 (patch) | |
tree | 8a4af35bd8fb2ca553025388532ef43b67408560 | |
parent | 118fb9b15ba62837a0befaad0aaea156b0488aea (diff) | |
download | timeline-5849d34d9fcf1ccfb7fe5cc0842765129f7198b4.tar.gz timeline-5849d34d9fcf1ccfb7fe5cc0842765129f7198b4.tar.bz2 timeline-5849d34d9fcf1ccfb7fe5cc0842765129f7198b4.zip |
fix: Fix migration bug.
-rw-r--r-- | BackEnd/Timeline/Program.cs | 14 | ||||
-rw-r--r-- | BackEnd/Timeline/Properties/launchSettings.json | 5 | ||||
-rw-r--r-- | BackEnd/Timeline/Services/Migration/CustomMigrationManager.cs | 4 |
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);
}
}
}
|