|
|
|
@ -1,15 +1,14 @@ |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Serilog; |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.Data; |
|
|
|
using Volo.Abp.DistributedLocking; |
|
|
|
using Volo.Abp.EventBus.Distributed; |
|
|
|
using Volo.Abp.MultiTenancy; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
using Volo.Abp.VirtualFileSystem; |
|
|
|
|
|
|
|
namespace EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.EfCore; |
|
|
|
|
|
|
|
@ -41,7 +40,7 @@ public abstract class PendingEfCoreMigrationsChecker<TDbContext> : PendingMigrat |
|
|
|
|
|
|
|
public virtual async Task CheckAndApplyDatabaseMigrationsAsync() |
|
|
|
{ |
|
|
|
await TryAsync(LockAndApplyDatabaseMigrationsAsync); |
|
|
|
await TryAsync(LockAndApplyDatabaseMigrationsAsync); |
|
|
|
} |
|
|
|
|
|
|
|
protected virtual async Task LockAndApplyDatabaseMigrationsAsync() |
|
|
|
@ -49,6 +48,13 @@ public abstract class PendingEfCoreMigrationsChecker<TDbContext> : PendingMigrat |
|
|
|
await using (var handle = await DistributedLockProvider.TryAcquireAsync("Migration_" + DatabaseName)) |
|
|
|
{ |
|
|
|
Log.Information($"Lock is acquired for db migration and seeding on database named: {DatabaseName}..."); |
|
|
|
|
|
|
|
if (handle is null) |
|
|
|
{ |
|
|
|
Log.Information($"Handle is null because of the locking for : {DatabaseName}"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
using (CurrentTenant.Change(null)) |
|
|
|
{ |
|
|
|
// Create database tables if needed
|
|
|
|
|