1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-15 09:43:35 -05:00

update for database provider specific migrations

fix issues with live radar
This commit is contained in:
RaidMax
2020-11-27 21:52:52 -06:00
parent 37a0e92cbd
commit e0ef55a636
309 changed files with 76554 additions and 1067 deletions

View File

@ -2,31 +2,30 @@
using SharedLibraryCore.Database.Models;
using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using SharedLibraryCore.Interfaces;
using static SharedLibraryCore.Database.Models.EFClient;
namespace SharedLibraryCore.Database
{
public class ContextSeed
public static class ContextSeed
{
private DatabaseContext context;
public ContextSeed(DatabaseContext ctx)
public static async Task Seed(IDatabaseContextFactory contextFactory, CancellationToken token)
{
context = ctx;
}
var context = contextFactory.CreateContext();
var strategy = context.Database.CreateExecutionStrategy();
await strategy.ExecuteAsync(async () =>
{
await context.Database.MigrateAsync(token);
});
public async Task Seed()
{
context.Database.Migrate();
if (context.AliasLinks.Count() == 0)
if (!await context.AliasLinks.AnyAsync(token))
{
var link = new EFAliasLink();
context.Clients.Add(new EFClient()
{
ClientId = 1,
Active = false,
Connections = 0,
FirstConnection = DateTime.UtcNow,
@ -44,8 +43,8 @@ namespace SharedLibraryCore.Database
},
});
await context.SaveChangesAsync();
await context.SaveChangesAsync(token);
}
}
}
}
}