If announcement table can't be found, migration will skip it
This commit is contained in:
parent
3d71e550ce
commit
e4bcb5a713
@ -89,54 +89,66 @@ namespace NadekoBot.Modules.Administration
|
|||||||
db.Open();
|
db.Open();
|
||||||
|
|
||||||
var com = db.CreateCommand();
|
var com = db.CreateCommand();
|
||||||
com.CommandText = "SELECT * FROM Announcement";
|
|
||||||
|
|
||||||
var reader = com.ExecuteReader();
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
while (reader.Read())
|
try
|
||||||
{
|
{
|
||||||
var gid = (ulong)(long)reader["ServerId"];
|
com.CommandText = "SELECT * FROM Announcement";
|
||||||
var greet = (long)reader["Greet"] == 1;
|
|
||||||
var greetDM = (long)reader["GreetPM"] == 1;
|
|
||||||
var greetChannel = (ulong)(long)reader["GreetChannelId"];
|
|
||||||
var greetMsg = (string)reader["GreetText"];
|
|
||||||
var bye = (long)reader["Bye"] == 1;
|
|
||||||
var byeDM = (long)reader["ByePM"] == 1;
|
|
||||||
var byeChannel = (ulong)(long)reader["ByeChannelId"];
|
|
||||||
var byeMsg = (string)reader["ByeText"];
|
|
||||||
var grdel = false;
|
|
||||||
var byedel = grdel;
|
|
||||||
var gc = uow.GuildConfigs.For(gid, set => set);
|
|
||||||
|
|
||||||
if (greetDM)
|
var reader = com.ExecuteReader();
|
||||||
gc.SendDmGreetMessage = greet;
|
while (reader.Read())
|
||||||
else
|
{
|
||||||
gc.SendChannelGreetMessage = greet;
|
var gid = (ulong)(long)reader["ServerId"];
|
||||||
gc.GreetMessageChannelId = greetChannel;
|
var greet = (long)reader["Greet"] == 1;
|
||||||
gc.ChannelGreetMessageText = greetMsg;
|
var greetDM = (long)reader["GreetPM"] == 1;
|
||||||
|
var greetChannel = (ulong)(long)reader["GreetChannelId"];
|
||||||
|
var greetMsg = (string)reader["GreetText"];
|
||||||
|
var bye = (long)reader["Bye"] == 1;
|
||||||
|
var byeDM = (long)reader["ByePM"] == 1;
|
||||||
|
var byeChannel = (ulong)(long)reader["ByeChannelId"];
|
||||||
|
var byeMsg = (string)reader["ByeText"];
|
||||||
|
var grdel = false;
|
||||||
|
var byedel = grdel;
|
||||||
|
var gc = uow.GuildConfigs.For(gid, set => set);
|
||||||
|
|
||||||
gc.SendChannelByeMessage = bye;
|
if (greetDM)
|
||||||
gc.ByeMessageChannelId = byeChannel;
|
gc.SendDmGreetMessage = greet;
|
||||||
gc.ChannelByeMessageText = byeMsg;
|
else
|
||||||
|
gc.SendChannelGreetMessage = greet;
|
||||||
|
gc.GreetMessageChannelId = greetChannel;
|
||||||
|
gc.ChannelGreetMessageText = greetMsg;
|
||||||
|
|
||||||
gc.AutoDeleteGreetMessagesTimer = gc.AutoDeleteByeMessagesTimer = grdel ? 30 : 0;
|
gc.SendChannelByeMessage = bye;
|
||||||
_log.Info(++i);
|
gc.ByeMessageChannelId = byeChannel;
|
||||||
|
gc.ChannelByeMessageText = byeMsg;
|
||||||
|
|
||||||
|
gc.AutoDeleteGreetMessagesTimer = gc.AutoDeleteByeMessagesTimer = grdel ? 30 : 0;
|
||||||
|
_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;
|
||||||
var reader2 = com.ExecuteReader();
|
try
|
||||||
while (reader2.Read())
|
|
||||||
{
|
{
|
||||||
_log.Info(++i);
|
var reader2 = com.ExecuteReader();
|
||||||
var curr = new Currency()
|
while (reader2.Read())
|
||||||
{
|
{
|
||||||
Amount = (long)reader2["Value"],
|
_log.Info(++i);
|
||||||
UserId = (ulong)(long)reader2["UserId"]
|
var curr = new Currency()
|
||||||
};
|
{
|
||||||
uow.Currency.Add(curr);
|
Amount = (long)reader2["Value"],
|
||||||
|
UserId = (ulong)(long)reader2["UserId"]
|
||||||
|
};
|
||||||
|
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 { }
|
||||||
|
Loading…
Reference in New Issue
Block a user