Update Version number to 3.5 and remove database migration script

This commit is contained in:
Runebaas 2017-11-16 10:27:59 +01:00
parent f0ba7bb9fc
commit 119ce579b7
No known key found for this signature in database
GPG key ID: 2677AF508D0300D6
3 changed files with 1 additions and 70 deletions

View file

@ -3,7 +3,7 @@
public class Constants
{
public const string Name = "Geekbot";
public const double BotVersion = 3.4;
public const double BotVersion = 3.5;
public const double ApiVersion = 1;
}
}

View file

@ -1,51 +0,0 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Serilog;
using StackExchange.Redis;
namespace Geekbot.net.Lib
{
public class DbMigration
{
public static Task MigrateDatabaseToHash(IDatabase redis, ILogger logger)
{
foreach (var key in redis.Multiplexer.GetServer("127.0.0.1", 6379).Keys(6))
{
var keyParts = key.ToString().Split("-");
if (keyParts.Length == 2 || keyParts.Length == 3)
{
logger.Verbose($"Migrating key {key}");
var stuff = new List<string>();
stuff.Add("messages");
stuff.Add("karma");
stuff.Add("welcomeMsg");
stuff.Add("correctRolls");
if(stuff.Contains(keyParts[keyParts.Length - 1]))
{
var val = redis.StringGet(key);
ulong.TryParse(keyParts[0], out ulong guildId);
ulong.TryParse(keyParts[1], out ulong userId);
switch (keyParts[keyParts.Length - 1])
{
case "messages":
redis.HashSet($"{guildId}:Messages", new HashEntry[] { new HashEntry(userId.ToString(), val) });
break;
case "karma":
redis.HashSet($"{guildId}:Karma", new HashEntry[] { new HashEntry(userId.ToString(), val) });
break;
case "correctRolls":
redis.HashSet($"{guildId}:Rolls", new HashEntry[] { new HashEntry(userId.ToString(), val) });
break;
case "welcomeMsg":
redis.HashSet($"{guildId}:Settings", new HashEntry[] { new HashEntry("WelcomeMsg", val) });
break;
}
}
redis.KeyDelete(key);
}
}
return Task.CompletedTask;
}
}
}

View file

@ -79,24 +79,6 @@ namespace Geekbot.net
logger.Fatal(e, "[Redis] Redis Connection Failed");
Environment.Exit(102);
}
if (args.Contains("--migrate"))
{
Console.WriteLine("\nYou are about to migrate the database, this will overwrite an already migrated database?");
Console.Write("Are you sure [y:N]: ");
var migrateDbConfirm = Console.ReadKey();
Console.WriteLine();
if (migrateDbConfirm.Key == ConsoleKey.Y)
{
logger.Warning("[Geekbot] Starting Migration");
await DbMigration.MigrateDatabaseToHash(redis, logger);
logger.Warning("[Geekbot] Finished Migration");
}
else
{
logger.Information("[Geekbot] Not Migrating db");
}
}
token = redis.StringGet("discordToken");
if (token.IsNullOrEmpty)