HostData ayrımı yapıldı.
This commit is contained in:
parent
b38aabb5bd
commit
7d006e0d74
5 changed files with 33 additions and 6 deletions
|
|
@ -72,7 +72,7 @@ public class PlatformIdentityDataSeeder : IdentityDataSeeder
|
||||||
Website = PlatformConsts.Branches.BranchWebsite,
|
Website = PlatformConsts.Branches.BranchWebsite,
|
||||||
IsActive = PlatformConsts.Branches.BranchIsActive,
|
IsActive = PlatformConsts.Branches.BranchIsActive,
|
||||||
TenantId = tenantId,
|
TenantId = tenantId,
|
||||||
});
|
}, autoSave: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName));
|
var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName));
|
||||||
|
|
@ -140,7 +140,7 @@ public class PlatformIdentityDataSeeder : IdentityDataSeeder
|
||||||
BranchId = branchId,
|
BranchId = branchId,
|
||||||
UserId = userId,
|
UserId = userId,
|
||||||
TenantId = tenantId
|
TenantId = tenantId
|
||||||
});
|
}, autoSave: true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,8 @@ public class SqlDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sqlFiles = Directory.GetFiles(sqlDataPath, "*.sql")
|
var isHostSeed = context.TenantId == null;
|
||||||
.OrderBy(f => Path.GetFileName(f))
|
var sqlFiles = GetSqlFiles(sqlDataPath, isHostSeed);
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
if (sqlFiles.Length == 0)
|
if (sqlFiles.Length == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -52,9 +51,10 @@ public class SqlDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
}
|
}
|
||||||
|
|
||||||
_logger.LogInformation(
|
_logger.LogInformation(
|
||||||
"SqlDataSeeder started for provider '{Provider}' from Seeds/{DirectoryName}. {Count} file(s) to be processed.",
|
"SqlDataSeeder started for provider '{Provider}' from Seeds/{DirectoryName}. Seed target: {SeedTarget}. {Count} file(s) to be processed.",
|
||||||
DefaultDatabaseProvider,
|
DefaultDatabaseProvider,
|
||||||
dataDirectoryName,
|
dataDirectoryName,
|
||||||
|
isHostSeed ? "Host" : "Tenant",
|
||||||
sqlFiles.Length);
|
sqlFiles.Length);
|
||||||
|
|
||||||
var dbContext = await _dbContextProvider.GetDbContextAsync();
|
var dbContext = await _dbContextProvider.GetDbContextAsync();
|
||||||
|
|
@ -111,6 +111,25 @@ public class SqlDataSeeder : IDataSeedContributor, ITransientDependency
|
||||||
: "SqlData";
|
: "SqlData";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string[] GetSqlFiles(string dataDirectoryPath, bool includeHostData)
|
||||||
|
{
|
||||||
|
var sqlFiles = Directory.GetFiles(dataDirectoryPath, "*.sql")
|
||||||
|
.OrderBy(f => Path.GetFileName(f))
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
if (includeHostData)
|
||||||
|
{
|
||||||
|
var hostDataPath = Path.Combine(dataDirectoryPath, "HostData");
|
||||||
|
if (Directory.Exists(hostDataPath))
|
||||||
|
{
|
||||||
|
sqlFiles.AddRange(Directory.GetFiles(hostDataPath, "*.sql")
|
||||||
|
.OrderBy(f => Path.GetFileName(f)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sqlFiles.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
private static (string Action, string? ObjectName, string? ObjectType) ExtractSqlInfo(string sql)
|
private static (string Action, string? ObjectName, string? ObjectType) ExtractSqlInfo(string sql)
|
||||||
{
|
{
|
||||||
var patterns = new[]
|
var patterns = new[]
|
||||||
|
|
|
||||||
|
|
@ -85,10 +85,18 @@
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Seeds\SqlData\HostData\*.sql">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Seeds\PostgresData\*.sql">
|
<Content Include="Seeds\PostgresData\*.sql">
|
||||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
<Content Include="Seeds\PostgresData\HostData\*.sql">
|
||||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue