Add 'backend/' from commit '040cfd7a75423d4e6136e58a67b40579af4ee966'

git-subtree-dir: backend
git-subtree-mainline: ab911955ed
git-subtree-split: 040cfd7a75
This commit is contained in:
2025-01-15 15:24:30 -05:00
179 changed files with 14349 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
using Hutopy.Web.Features.Contents.Data;
namespace Hutopy.Web.Features.Memberships.Data;
public static class InitializerExtensions
{
public static async Task InitialiseMembershipDbContextAsync(this WebApplication app)
{
using var scope = app.Services.CreateScope();
var initializer = scope.ServiceProvider.GetRequiredService<MembershipDbContextInitializer>();
await initializer.InitialiseAsync();
}
}
public class MembershipDbContextInitializer(
ILogger<MembershipDbContextInitializer> logger,
MembershipDbContext context
)
{
public async Task InitialiseAsync()
{
try
{
await context.Database.MigrateAsync();
}
catch (Exception ex)
{
logger.LogError(ex, "An error occurred while initialising the membership database.");
throw;
}
}
}