excise entity framework from all remaining code

This commit is contained in:
sam 2024-10-28 14:04:55 +01:00
parent d6c3133d52
commit ff92c5f335
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
62 changed files with 402 additions and 1339 deletions

View file

@ -22,12 +22,9 @@ using Catalogger.Backend.Cache;
using Catalogger.Backend.Cache.InMemoryCache;
using Catalogger.Backend.Cache.RedisCache;
using Catalogger.Backend.Database;
using Catalogger.Backend.Database.Dapper;
using Catalogger.Backend.Database.Dapper.Repositories;
using Catalogger.Backend.Database.Queries;
using Catalogger.Backend.Database.Redis;
using Catalogger.Backend.Database.Repositories;
using Catalogger.Backend.Services;
using Microsoft.EntityFrameworkCore;
using NodaTime;
using Prometheus;
using Remora.Discord.API;
@ -106,6 +103,7 @@ public static class StartupExtensions
services
.AddSingleton<IClock>(SystemClock.Instance)
.AddDatabasePool()
.AddScoped<DatabaseMigrator>()
.AddScoped<MessageRepository>()
.AddScoped<GuildRepository>()
.AddScoped<InviteRepository>()
@ -159,6 +157,7 @@ public static class StartupExtensions
return services;
return services
.AddScoped<ApiTokenRepository>()
.AddScoped<ApiCache>()
.AddScoped<DiscordRequestService>()
.AddScoped<AuthenticationMiddleware>()
@ -197,17 +196,8 @@ public static class StartupExtensions
DatabasePool.ConfigureDapper();
await using (var db = scope.ServiceProvider.GetRequiredService<DatabaseContext>())
{
var migrationCount = (await db.Database.GetPendingMigrationsAsync()).Count();
if (migrationCount != 0)
{
logger.Information("Applying {Count} database migrations", migrationCount);
await db.Database.MigrateAsync();
}
else
logger.Information("There are no pending migrations");
}
await using var migrator = scope.ServiceProvider.GetRequiredService<DatabaseMigrator>();
await migrator.Migrate();
var config = scope.ServiceProvider.GetRequiredService<Config>();
var slashService = scope.ServiceProvider.GetRequiredService<SlashService>();