diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PlatformIdentityDataSeeder.cs b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PlatformIdentityDataSeeder.cs
index ed4cc9d..af7a7ea 100644
--- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PlatformIdentityDataSeeder.cs
+++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PlatformIdentityDataSeeder.cs
@@ -72,7 +72,7 @@ public class PlatformIdentityDataSeeder : IdentityDataSeeder
Website = PlatformConsts.Branches.BranchWebsite,
IsActive = PlatformConsts.Branches.BranchIsActive,
TenantId = tenantId,
- });
+ }, autoSave: true);
}
var adminRole = await RoleRepository.FindByNormalizedNameAsync(LookupNormalizer.NormalizeName(PlatformConsts.AbpIdentity.User.AdminRoleName));
@@ -140,7 +140,7 @@ public class PlatformIdentityDataSeeder : IdentityDataSeeder
BranchId = branchId,
UserId = userId,
TenantId = tenantId
- });
+ }, autoSave: true);
}
}
diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/PostgresData/Sas_H_BackgroundWorker_JobFlow.sql b/api/src/Sozsoft.Platform.DbMigrator/Seeds/PostgresData/HostData/Sas_H_BackgroundWorker_JobFlow.sql
similarity index 100%
rename from api/src/Sozsoft.Platform.DbMigrator/Seeds/PostgresData/Sas_H_BackgroundWorker_JobFlow.sql
rename to api/src/Sozsoft.Platform.DbMigrator/Seeds/PostgresData/HostData/Sas_H_BackgroundWorker_JobFlow.sql
diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlData/Sas_H_BackgroundWorker_JobFlow.sql b/api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlData/HostData/Sas_H_BackgroundWorker_JobFlow.sql
similarity index 100%
rename from api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlData/Sas_H_BackgroundWorker_JobFlow.sql
rename to api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlData/HostData/Sas_H_BackgroundWorker_JobFlow.sql
diff --git a/api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlDataSeeder.cs b/api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlDataSeeder.cs
index d4a2ce7..2fbf4e4 100644
--- a/api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlDataSeeder.cs
+++ b/api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlDataSeeder.cs
@@ -41,9 +41,8 @@ public class SqlDataSeeder : IDataSeedContributor, ITransientDependency
return;
}
- var sqlFiles = Directory.GetFiles(sqlDataPath, "*.sql")
- .OrderBy(f => Path.GetFileName(f))
- .ToArray();
+ var isHostSeed = context.TenantId == null;
+ var sqlFiles = GetSqlFiles(sqlDataPath, isHostSeed);
if (sqlFiles.Length == 0)
{
@@ -52,9 +51,10 @@ public class SqlDataSeeder : IDataSeedContributor, ITransientDependency
}
_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,
dataDirectoryName,
+ isHostSeed ? "Host" : "Tenant",
sqlFiles.Length);
var dbContext = await _dbContextProvider.GetDbContextAsync();
@@ -111,6 +111,25 @@ public class SqlDataSeeder : IDataSeedContributor, ITransientDependency
: "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)
{
var patterns = new[]
diff --git a/api/src/Sozsoft.Platform.DbMigrator/Sozsoft.Platform.DbMigrator.csproj b/api/src/Sozsoft.Platform.DbMigrator/Sozsoft.Platform.DbMigrator.csproj
index de9f498..0ca93d0 100644
--- a/api/src/Sozsoft.Platform.DbMigrator/Sozsoft.Platform.DbMigrator.csproj
+++ b/api/src/Sozsoft.Platform.DbMigrator/Sozsoft.Platform.DbMigrator.csproj
@@ -85,10 +85,18 @@
PreserveNewest
Always
+
+ PreserveNewest
+ Always
+
PreserveNewest
Always
+
+ PreserveNewest
+ Always
+