From 9470e06c0fd1551c9ca498b085f81424b7657cc7 Mon Sep 17 00:00:00 2001 From: ChiaraBm Date: Thu, 12 Mar 2026 14:43:04 +0000 Subject: [PATCH] Changed migration history table to specific schema. Added log for applied migrations --- MoonlightServers.Api/Infrastructure/Database/DataContext.cs | 1 + .../Infrastructure/Database/DbMigrationService.cs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/MoonlightServers.Api/Infrastructure/Database/DataContext.cs b/MoonlightServers.Api/Infrastructure/Database/DataContext.cs index b0b624c..613732c 100644 --- a/MoonlightServers.Api/Infrastructure/Database/DataContext.cs +++ b/MoonlightServers.Api/Infrastructure/Database/DataContext.cs @@ -32,6 +32,7 @@ public class DataContext : DbContext builder => { builder.MigrationsAssembly(typeof(DbContext).Assembly); + builder.MigrationsHistoryTable("__EFMigrationsHistory", "severs"); } ); } diff --git a/MoonlightServers.Api/Infrastructure/Database/DbMigrationService.cs b/MoonlightServers.Api/Infrastructure/Database/DbMigrationService.cs index 6d885e0..403c09a 100644 --- a/MoonlightServers.Api/Infrastructure/Database/DbMigrationService.cs +++ b/MoonlightServers.Api/Infrastructure/Database/DbMigrationService.cs @@ -23,6 +23,9 @@ public class DbMigrationService : IHostedLifecycleService await using var scope = ServiceProvider.CreateAsyncScope(); var context = scope.ServiceProvider.GetRequiredService(); + var appliedMigrations = await context.Database.GetAppliedMigrationsAsync(cancellationToken); + Logger.LogTrace("Applied migrations: {names}", string.Join(", ", appliedMigrations)); + var pendingMigrations = await context.Database.GetPendingMigrationsAsync(cancellationToken); var migrationNames = pendingMigrations.ToArray();