added config db

This commit is contained in:
Flaminel
2025-06-13 18:12:25 +03:00
parent 0cb737a7e1
commit 9353a55cff
12 changed files with 75 additions and 49 deletions

View File

@@ -12,9 +12,9 @@ namespace Executable.Controllers;
[Route("api/[controller]")]
public class EventsController : ControllerBase
{
private readonly DataContext _context;
private readonly EventsContext _context;
public EventsController(DataContext context)
public EventsController(EventsContext context)
{
_context = context;
}
@@ -66,7 +66,7 @@ public class EventsController : ControllerBase
// Apply search filter if provided
if (!string.IsNullOrWhiteSpace(search))
{
string pattern = DataContext.GetLikePattern(search);
string pattern = EventsContext.GetLikePattern(search);
query = query.Where(e =>
EF.Functions.Like(e.Message, pattern) ||
EF.Functions.Like(e.Data, pattern) ||

View File

@@ -1,7 +1,5 @@
using Common.Helpers;
using Common.Helpers;
using Data.Enums;
using Infrastructure.Configuration;
using Infrastructure.Verticals.ContentBlocker;
using Infrastructure.Verticals.DownloadCleaner;
using Infrastructure.Verticals.QueueCleaner;
using Serilog;

View File

@@ -25,7 +25,7 @@ public static class ServicesDI
services
.AddSingleton<IEncryptionService, AesEncryptionService>()
.AddTransient<SensitiveDataJsonConverter>()
.AddTransient<DataContext>()
.AddTransient<EventsContext>()
.AddTransient<EventPublisher>()
.AddHostedService<EventCleanupService>()
// API services

View File

@@ -34,10 +34,16 @@ public static class HostExtensions
}
// Apply db migrations
var dbContext = host.Services.GetRequiredService<DataContext>();
if ((await dbContext.Database.GetPendingMigrationsAsync()).Any())
var eventsContext = host.Services.GetRequiredService<EventsContext>();
if ((await eventsContext.Database.GetPendingMigrationsAsync()).Any())
{
await dbContext.Database.MigrateAsync();
await eventsContext.Database.MigrateAsync();
}
var configContext = host.Services.GetRequiredService<DataContext>();
if ((await configContext.Database.GetPendingMigrationsAsync()).Any())
{
await configContext.Database.MigrateAsync();
}
return host;