If announcement table can't be found, migration will skip it

This commit is contained in:
Kwoth 2017-01-14 17:59:35 +01:00
parent 3d71e550ce
commit e4bcb5a713

View File

@ -89,10 +89,12 @@ namespace NadekoBot.Modules.Administration
db.Open(); db.Open();
var com = db.CreateCommand(); var com = db.CreateCommand();
var i = 0;
try
{
com.CommandText = "SELECT * FROM Announcement"; com.CommandText = "SELECT * FROM Announcement";
var reader = com.ExecuteReader(); var reader = com.ExecuteReader();
var i = 0;
while (reader.Read()) while (reader.Read())
{ {
var gid = (ulong)(long)reader["ServerId"]; var gid = (ulong)(long)reader["ServerId"];
@ -122,11 +124,16 @@ namespace NadekoBot.Modules.Administration
gc.AutoDeleteGreetMessagesTimer = gc.AutoDeleteByeMessagesTimer = grdel ? 30 : 0; gc.AutoDeleteGreetMessagesTimer = gc.AutoDeleteByeMessagesTimer = grdel ? 30 : 0;
_log.Info(++i); _log.Info(++i);
} }
}
catch {
_log.Warn("Greet/bye messages won't be migrated");
}
var com2 = db.CreateCommand(); var com2 = db.CreateCommand();
com.CommandText = "SELECT * FROM CurrencyState GROUP BY UserId"; com.CommandText = "SELECT * FROM CurrencyState GROUP BY UserId";
i = 0; i = 0;
try
{
var reader2 = com.ExecuteReader(); var reader2 = com.ExecuteReader();
while (reader2.Read()) while (reader2.Read())
{ {
@ -138,6 +145,11 @@ namespace NadekoBot.Modules.Administration
}; };
uow.Currency.Add(curr); uow.Currency.Add(curr);
} }
}
catch
{
_log.Warn("Currency won't be migrated");
}
db.Close(); db.Close();
try { File.Move("data/nadekobot.sqlite", "data/DELETE_ME_nadekobot.sqlite"); } catch { } try { File.Move("data/nadekobot.sqlite", "data/DELETE_ME_nadekobot.sqlite"); } catch { }
} }