From 3c1167d35936f85c8a468beb6b6455719a64b3b4 Mon Sep 17 00:00:00 2001 From: sbwalker Date: Fri, 19 Sep 2025 15:25:11 -0400 Subject: [PATCH] improve migration history --- .../Modules/Admin/SystemInfo/Index.razor | 18 +++++++++++++++--- .../Modules/Admin/SystemInfo/Index.resx | 6 ++++++ .../Repository/Context/MasterDBContext.cs | 1 - .../Repository/Context/TenantDBContext.cs | 1 + .../Repository/MigrationHistoryRepository.cs | 10 ++++++---- 5 files changed, 28 insertions(+), 8 deletions(-) diff --git a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor index ca32bf86..3ce9f92f 100644 --- a/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor +++ b/Oqtane.Client/Modules/Admin/SystemInfo/Index.razor @@ -3,6 +3,7 @@ @inject ISystemService SystemService @inject IInstallationService InstallationService @inject IMigrationHistoryService MigrationHistoryService +@inject ITenantService TenantService @inject IStringLocalizer Localizer @inject IStringLocalizer SharedLocalizer @@ -174,11 +175,19 @@ +
+
+ +
+ +
+
+
- @Localizer["Migration"] - @Localizer["Date"] - @Localizer["Version"] + @Localizer["Migration"] + @Localizer["Date"] + @Localizer["Version"]
@context.MigrationId @@ -219,6 +228,7 @@ private string _log = string.Empty; + private string _tenant = string.Empty; private List _history; protected override async Task OnInitializedAsync() @@ -259,6 +269,8 @@ _log = systeminfo["Log"].ToString(); } + var tenants = await TenantService.GetTenantsAsync(); + _tenant = tenants.Find(item => item.TenantId == PageState.Site.TenantId).Name; _history = await MigrationHistoryService.GetMigrationHistoryAsync(); _initialized = true; diff --git a/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx b/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx index d276da67..a4a292d4 100644 --- a/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx +++ b/Oqtane.Client/Resources/Modules/Admin/SystemInfo/Index.resx @@ -318,4 +318,10 @@ Framework Version + + Database: + + + The name of the current database. Note that this is not the physical database name but rather the tenant name which is used within the framework to identify a database. + \ No newline at end of file diff --git a/Oqtane.Server/Repository/Context/MasterDBContext.cs b/Oqtane.Server/Repository/Context/MasterDBContext.cs index 1e8f6a1e..4ade9f28 100644 --- a/Oqtane.Server/Repository/Context/MasterDBContext.cs +++ b/Oqtane.Server/Repository/Context/MasterDBContext.cs @@ -69,7 +69,6 @@ namespace Oqtane.Repository public virtual DbSet JobLog { get; set; } public virtual DbSet Setting { get; set; } public virtual DbSet Theme { get; set; } - public virtual DbSet MigrationHistory { get; set; } public override int SaveChanges() { diff --git a/Oqtane.Server/Repository/Context/TenantDBContext.cs b/Oqtane.Server/Repository/Context/TenantDBContext.cs index 599485f7..bb0e1c72 100644 --- a/Oqtane.Server/Repository/Context/TenantDBContext.cs +++ b/Oqtane.Server/Repository/Context/TenantDBContext.cs @@ -33,5 +33,6 @@ namespace Oqtane.Repository public virtual DbSet SearchContentProperty { get; set; } public virtual DbSet SearchContentWord { get; set; } public virtual DbSet SearchWord { get; set; } + public virtual DbSet MigrationHistory { get; set; } } } diff --git a/Oqtane.Server/Repository/MigrationHistoryRepository.cs b/Oqtane.Server/Repository/MigrationHistoryRepository.cs index 27068198..5465dc08 100644 --- a/Oqtane.Server/Repository/MigrationHistoryRepository.cs +++ b/Oqtane.Server/Repository/MigrationHistoryRepository.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using Microsoft.EntityFrameworkCore; using Oqtane.Models; namespace Oqtane.Repository @@ -10,16 +11,17 @@ namespace Oqtane.Repository } public class MigrationHistoryRepository : IMigrationHistoryRepository { - private MasterDBContext _db; + private readonly IDbContextFactory _dbContextFactory; - public MigrationHistoryRepository(MasterDBContext context) + public MigrationHistoryRepository(IDbContextFactory dbContextFactory) { - _db = context; + _dbContextFactory = dbContextFactory; } public IEnumerable GetMigrationHistory() { - return _db.MigrationHistory.ToList(); + using var db = _dbContextFactory.CreateDbContext(); + return db.MigrationHistory.ToList(); } } }