[Activity] Add database backup on migration

This commit is contained in:
2023-04-10 12:38:11 +02:00
parent 4b23dfd8a0
commit ad4ee02631

View File

@@ -93,6 +93,12 @@ await using(var scope = host.Services.CreateAsyncScope())
}
else
{
// Backup database before migrations
if (File.Exists("cocotte.db"))
{
File.Copy("cocotte.db", $"cocotte.{DateTime.UtcNow:s}.db");
}
// Apply migrations
await dbContext.Database.MigrateAsync();
}