Remove old master database if there is a new database schema.

This commit is contained in:
2019-12-07 17:34:38 +00:00
parent b81c794ce1
commit e6f5b0f9ca

View File

@@ -32,6 +32,7 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
@@ -84,8 +85,23 @@ namespace DiscImageChef
}
var mctx = DicContext.Create(Settings.Settings.MasterDbPath);
mctx.Database.Migrate();
mctx.SaveChanges();
if(mctx.Database.GetPendingMigrations().Any())
{
DicConsole.WriteLine("New database version, updating...");
try
{
File.Delete(Settings.Settings.MasterDbPath);
}
catch(Exception)
{
DicConsole.ErrorWriteLine("Exception trying to remove old database version, cannot continue...");
DicConsole.ErrorWriteLine("Please manually remove file at {0}", Settings.Settings.MasterDbPath);
}
UpdateCommand.DoUpdate(true);
}
if ((args.Length < 1 || args[0].ToLowerInvariant() != "gui") &&
Settings.Settings.Current.GdprCompliance < DicSettings.GdprLevel)