Browse Source
Merge pull request #3307 from abpframework/maliming/patch-2
Migrate only tenants with connection strings.
pull/3326/head
Galip Tolga Erdem
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
5 additions and
5 deletions
-
templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Domain/Data/MyProjectNameDbMigrationService.cs
|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Microsoft.Extensions.Logging; |
|
|
|
using Microsoft.Extensions.Logging.Abstractions; |
|
|
|
@ -38,15 +39,14 @@ namespace MyCompanyName.MyProjectName.Data |
|
|
|
|
|
|
|
await MigrateHostDatabaseAsync(); |
|
|
|
|
|
|
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
|
|
|
|
|
|
|
var i = 0; |
|
|
|
var tenants = await _tenantRepository.GetListAsync(); |
|
|
|
foreach (var tenant in tenants) |
|
|
|
foreach (var tenant in tenants.Where(t => t.ConnectionStrings.Any())) |
|
|
|
{ |
|
|
|
i++; |
|
|
|
|
|
|
|
using (_currentTenant.Change(tenant.Id)) |
|
|
|
{ |
|
|
|
Logger.LogInformation($"Migrating {tenant.Name} database schema... ({i} of {tenants.Count})"); |
|
|
|
Logger.LogInformation($"Migrating {tenant.Name} database schema... ({++i} of {tenants.Count})"); |
|
|
|
await MigrateTenantDatabasesAsync(tenant); |
|
|
|
Logger.LogInformation($"Successfully completed {tenant.Name} database migrations."); |
|
|
|
} |
|
|
|
|