migrations, query fixes, fixes for mysql and postgres. In progress

This commit is contained in:
Toastie 2024-09-12 15:44:35 +12:00
parent b04768633c
commit 40b4ebf0fa
Signed by: toastie_t0ast
GPG key ID: 27F3B6855AFD40A4
29 changed files with 18970 additions and 8070 deletions
src/EllieBot/Services/Impl

View file

@ -1,6 +1,5 @@
#nullable disable
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Primitives;
using EllieBot.Common.Yml;
namespace EllieBot.Services;
@ -22,7 +21,6 @@ public sealed class BotCredsProvider : IBotCredsProvider
private readonly object _reloadLock = new();
private readonly IDisposable _changeToken;
public BotCredsProvider(int? totalShards = null, string credPath = null)
{
@ -49,18 +47,18 @@ public sealed class BotCredsProvider : IBotCredsProvider
// this can fail in docker containers
}
MigrateCredentials();
if (!File.Exists(CredsPath))
{
Log.Warning(
"{CredsPath} is missing. Attempting to load creds from environment variables prefixed with 'EllieBot_'. Example is in {CredsExamplePath}",
CredsPath,
CredsExamplePath);
}
try
{
MigrateCredentials();
if (!File.Exists(CredsPath))
{
Log.Warning(
"{CredsPath} is missing. Attempting to load creds from environment variables prefixed with 'EllieBot_'. Example is in {CredsExamplePath}",
CredsPath,
CredsExamplePath);
}
_config = new ConfigurationBuilder().AddYamlFile(CredsPath, false, true)
.AddEnvironmentVariables("EllieBot_")
.Build();
@ -70,7 +68,6 @@ public sealed class BotCredsProvider : IBotCredsProvider
Console.WriteLine(ex.ToString());
}
_changeToken = ChangeToken.OnChange(() => _config.GetReloadToken(), Reload);
Reload();
}
@ -141,6 +138,7 @@ public sealed class BotCredsProvider : IBotCredsProvider
{
creds.BotCache = BotCacheImplemenation.Redis;
}
if (creds.Version <= 6)
{
creds.Version = 7;