Merge pull request #5642 from sbwalker/dev

improve migration history
This commit is contained in:
Shaun Walker
2025-09-19 15:25:25 -04:00
committed by GitHub
5 changed files with 28 additions and 8 deletions

View File

@ -3,6 +3,7 @@
@inject ISystemService SystemService
@inject IInstallationService InstallationService
@inject IMigrationHistoryService MigrationHistoryService
@inject ITenantService TenantService
@inject IStringLocalizer<Index> Localizer
@inject IStringLocalizer<SharedResources> SharedLocalizer
@ -174,11 +175,19 @@
<button type="button" class="btn btn-danger" @onclick="ClearLog">@Localizer["Clear"]</button>
</TabPanel>
<TabPanel Name="Migrations" Heading="Migrations" ResourceKey="Migrations">
<div class="container">
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="tenant" HelpText="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." ResourceKey="Tenant">Database: </Label>
<div class="col-sm-9">
<input id="tenant" class="form-control" @bind="@_tenant" readonly />
</div>
</div>
</div>
<Pager Items="@_history" SearchProperties="MigrationId">
<Header>
<th>@Localizer["Migration"]</th>
<th>@Localizer["Date"]</th>
<th>@Localizer["Version"]</th>
<th>@Localizer["Migration"]</th>
<th>@Localizer["Date"]</th>
<th>@Localizer["Version"]</th>
</Header>
<Row>
<td>@context.MigrationId</td>
@ -219,6 +228,7 @@
private string _log = string.Empty;
private string _tenant = string.Empty;
private List<MigrationHistory> _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;

View File

@ -318,4 +318,10 @@
<data name="Version" xml:space="preserve">
<value>Framework Version</value>
</data>
<data name="Tenant.Text" xml:space="preserve">
<value>Database:</value>
</data>
<data name="Tenant.HelpText" xml:space="preserve">
<value>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.</value>
</data>
</root>

View File

@ -69,7 +69,6 @@ namespace Oqtane.Repository
public virtual DbSet<JobLog> JobLog { get; set; }
public virtual DbSet<Setting> Setting { get; set; }
public virtual DbSet<Theme> Theme { get; set; }
public virtual DbSet<MigrationHistory> MigrationHistory { get; set; }
public override int SaveChanges()
{

View File

@ -33,5 +33,6 @@ namespace Oqtane.Repository
public virtual DbSet<SearchContentProperty> SearchContentProperty { get; set; }
public virtual DbSet<SearchContentWord> SearchContentWord { get; set; }
public virtual DbSet<SearchWord> SearchWord { get; set; }
public virtual DbSet<MigrationHistory> MigrationHistory { get; set; }
}
}

View File

@ -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<TenantDBContext> _dbContextFactory;
public MigrationHistoryRepository(MasterDBContext context)
public MigrationHistoryRepository(IDbContextFactory<TenantDBContext> dbContextFactory)
{
_db = context;
_dbContextFactory = dbContextFactory;
}
public IEnumerable<MigrationHistory> GetMigrationHistory()
{
return _db.MigrationHistory.ToList();
using var db = _dbContextFactory.CreateDbContext();
return db.MigrationHistory.ToList();
}
}
}