Fixed migration of currency from 0.9 to 1.0

This commit is contained in:
Kwoth 2016-11-10 22:31:15 +01:00
parent df8b67e3c8
commit 98576311c1

View File

@ -128,18 +128,19 @@ namespace NadekoBot.Modules.Administration
} }
var com2 = db.CreateCommand(); var com2 = db.CreateCommand();
com.CommandText = "SELECT * FROM CurrencyState"; com.CommandText = "SELECT * FROM CurrencyState GROUP BY UserId";
i = 0; i = 0;
var reader2 = com.ExecuteReader(); var reader2 = com.ExecuteReader();
while (reader2.Read()) while (reader2.Read())
{ {
_log.Info(++i); _log.Info(++i);
uow.Currency.Add(new Currency() var curr = new Currency()
{ {
Amount = (long)reader2["Value"], Amount = (long)reader2["Value"],
UserId = (ulong)(long)reader2["UserId"] UserId = (ulong)(long)reader2["UserId"]
}); };
uow.Currency.Add(curr);
} }
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 { }