From 7d006e0d74c8d9756c59a8453df63d95feddbc9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sedat=20=C3=96zt=C3=BCrk?= Date: Tue, 26 May 2026 19:49:46 +0300 Subject: [PATCH] =?UTF-8?q?HostData=20ayr=C4=B1m=C4=B1=20yap=C4=B1ld=C4=B1?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Seeds/PlatformIdentityDataSeeder.cs | 4 +-- .../Sas_H_BackgroundWorker_JobFlow.sql | 0 .../Sas_H_BackgroundWorker_JobFlow.sql | 0 .../Seeds/SqlDataSeeder.cs | 27 ++++++++++++++++--- .../Sozsoft.Platform.DbMigrator.csproj | 8 ++++++ 5 files changed, 33 insertions(+), 6 deletions(-) rename api/src/Sozsoft.Platform.DbMigrator/Seeds/PostgresData/{ => HostData}/Sas_H_BackgroundWorker_JobFlow.sql (100%) rename api/src/Sozsoft.Platform.DbMigrator/Seeds/SqlData/{ => HostData}/Sas_H_BackgroundWorker_JobFlow.sql (100%) 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 +