Browse Source

feat: Optimize microservice data seeds

pull/1470/head
colin 4 weeks ago
parent
commit
55b5469719
  1. 1
      aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/LY.MicroService.AuthServer.DbMigrator.csproj
  2. 96
      aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/appsettings.json
  3. 28
      aspnet-core/migrations/LY.MicroService.AuthServer.EntityFrameworkCore/AuthServerDbMigrationService.cs
  4. 7
      aspnet-core/migrations/LY.MicroService.AuthServer.EntityFrameworkCore/DataSeeds/IdentityClaimTypeDataSeeder.cs
  5. 26
      aspnet-core/migrations/LY.MicroService.AuthServer.EntityFrameworkCore/DataSeeds/IdentityUserRoleDataSeeder.cs
  6. 6
      aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.cs
  7. 3
      aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/LY.MicroService.BackendAdmin.DbMigrator.csproj
  8. 2
      aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/appsettings.json
  9. 10
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/AdminServiceDataSeeder.cs
  10. 4
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminDbMigrationEventHandler.cs
  11. 28
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminDbMigrationService.cs
  12. 2
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminMigrationsEntityFrameworkCoreModule.cs
  13. 5
      aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/appsettings.json
  14. 1
      aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LY.MicroService.LocalizationManagement.DbMigrator.csproj
  15. 5
      aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/appsettings.json
  16. 31
      aspnet-core/migrations/LY.MicroService.LocalizationManagement.EntityFrameworkCore/LocalizationManagementDbMigrationService.cs
  17. 1
      aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/LY.MicroService.Platform.DbMigrator.csproj
  18. 2
      aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/appsettings.json
  19. 1501
      aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20260424033808_Add-Blob-Management-Module.Designer.cs
  20. 116
      aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20260424033808_Add-Blob-Management-Module.cs
  21. 161
      aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/PlatformMigrationsDbContextModelSnapshot.cs
  22. 28
      aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/PlatformDbMigrationService.cs
  23. 4
      aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/PlatformMigrationsDbContext.cs
  24. 1
      aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/LY.MicroService.RealtimeMessage.DbMigrator.csproj
  25. 5
      aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json
  26. 31
      aspnet-core/migrations/LY.MicroService.RealtimeMessage.EntityFrameworkCore/RealtimeMessageDbMigrationService.cs
  27. 1
      aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/LY.MicroService.TaskManagement.DbMigrator.csproj
  28. 2
      aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.PostgreSql.json
  29. 5
      aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.json
  30. 8
      aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/TaskManagementDbMigrationEventHandler.cs
  31. 4
      aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/TaskServiceDataSeeder.cs
  32. 1
      aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/LY.MicroService.WebhooksManagement.DbMigrator.csproj
  33. 5
      aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/appsettings.json
  34. 5
      aspnet-core/migrations/LY.MicroService.WebhooksManagement.EntityFrameworkCore/WebhooksManagementDbMigrationEventHandler.cs
  35. 2
      aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.Application/LINGYUN/Abp/Gdpr/GdprRequestAppService.cs
  36. 2
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationMappers.cs
  37. 2
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationPublishContext.cs

1
aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/LY.MicroService.AuthServer.DbMigrator.csproj

@ -22,7 +22,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" />
</ItemGroup>
<ItemGroup>

96
aspnet-core/migrations/LY.MicroService.AuthServer.DbMigrator/appsettings.json

@ -1,78 +1,34 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Platform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Identity": "Server=127.0.0.1;Database=AuthServer-V70;User Id=root;Password=123456;SslMode=None",
"Realtime": "Server=127.0.0.1;Database=Messages-V70;User Id=root;Password=123456;SslMode=None"
"Default": "Server=localhost;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",
"InitVectorBytes": "s83ng0abvd02js84",
"DefaultSalt": "sf&5)s3#"
},
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"System": "Warning",
"Microsoft": "Warning",
"DotNetCore": "Information"
}
},
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ],
"WriteTo": [
{
"Name": "Console",
"Args": {
"restrictedToMinimumLevel": "Debug",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "Logs/Debug-.log",
"restrictedToMinimumLevel": "Debug",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "Logs/Info-.log",
"restrictedToMinimumLevel": "Information",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
},
{
"Name": "File",
"Args": {
"path": "Logs/Warn-.log",
"restrictedToMinimumLevel": "Warning",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
"OpenIddict": {
"Applications": {
"VueAdmin": {
"ClientId": "vue-admin-client",
"ClientSecret": "1q2w3e*",
"RootUrls": [ "http://localhost:5666" ]
},
{
"Name": "File",
"Args": {
"path": "Logs/Error-.log",
"restrictedToMinimumLevel": "Error",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
"InternalService": {
"ClientId": "InternalServiceClient",
"ClientSecret": "1q2w3e*"
},
{
"Name": "File",
"Args": {
"path": "Logs/Fatal-.log",
"restrictedToMinimumLevel": "Fatal",
"rollingInterval": "Day",
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}"
}
"VueOAuthClient": {
"ClientId": "vue-oauth-client",
"RootUrls": [
"http://localhost:5666",
"http://localhost:30000",
"http://localhost:30010",
"http://localhost:30015",
"http://localhost:30020",
"http://localhost:30025",
"http://localhost:30030",
"http://localhost:30040",
"http://localhost:30045",
"http://localhost:30050",
"http://localhost:30060"
]
}
]
}
}
}

28
aspnet-core/migrations/LY.MicroService.AuthServer.EntityFrameworkCore/AuthServerDbMigrationService.cs

@ -1,8 +1,6 @@
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.Saas.Tenants;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@ -15,14 +13,10 @@ namespace LY.MicroService.AuthServer.EntityFrameworkCore;
public class AuthServerDbMigrationService : EfCoreRuntimeDbMigratorBase<AuthServerMigrationsDbContext>, ITransientDependency
{
protected IDataSeeder DataSeeder { get; }
protected IDbSchemaMigrator DbSchemaMigrator { get; }
protected ITenantRepository TenantRepository { get; }
protected AuthServerDataSeeder DataSeeder { get; }
public AuthServerDbMigrationService(
IDataSeeder dataSeeder,
IDbSchemaMigrator dbSchemaMigrator,
ITenantRepository tenantRepository,
AuthServerDataSeeder dataSeeder,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IServiceProvider serviceProvider,
@ -34,25 +28,11 @@ public class AuthServerDbMigrationService : EfCoreRuntimeDbMigratorBase<AuthServ
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory)
{
DataSeeder = dataSeeder;
DbSchemaMigrator = dbSchemaMigrator;
TenantRepository = tenantRepository;
}
protected async override Task LockAndApplyDatabaseMigrationsAsync()
{
await base.LockAndApplyDatabaseMigrationsAsync();
var tenants = await TenantRepository.GetListAsync();
foreach (var tenant in tenants.Where(x => x.IsActive))
{
await LockAndApplyDatabaseWithTenantMigrationsAsync(tenant.Id);
}
}
protected async override Task SeedAsync()
{
Logger.LogInformation($"Executing {(!CurrentTenant.IsAvailable ? "host" : CurrentTenant.Name ?? CurrentTenant.GetId().ToString())} database seed...");
await DataSeeder.SeedAsync(CurrentTenant.Id);
// DbMigrator迁移数据种子
await DataSeeder.SeedAsync(new DataSeedContext());
}
}

7
aspnet-core/migrations/LY.MicroService.AuthServer.EntityFrameworkCore/DataSeeds/IdentityClaimTypeDataSeeder.cs

@ -1,5 +1,6 @@
using JetBrains.Annotations;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using OpenIddict.Abstractions;
using System.Threading.Tasks;
using Volo.Abp.Data;
@ -23,6 +24,8 @@ public class IdentityClaimTypeDataSeeder : ITransientDependency
GuidGenerator = guidGenerator;
IdentityClaimTypeManager = identityClaimTypeManager;
IdentityClaimTypeRepository = identityClaimTypeRepository;
Logger = NullLogger<IdentityClaimTypeDataSeeder>.Instance;
}
public async virtual Task SeedAsync(DataSeedContext context)
@ -72,8 +75,12 @@ public class IdentityClaimTypeDataSeeder : ITransientDependency
[CanBeNull] string description = null,
IdentityClaimValueType valueType = IdentityClaimValueType.String)
{
Logger.LogInformation("Check claim types {name} exists.", name);
if (!await IdentityClaimTypeRepository.AnyAsync(name))
{
Logger.LogInformation("Create new claim types {name}.", name);
await IdentityClaimTypeManager.CreateAsync(
new IdentityClaimType(
GuidGenerator.Create(),

26
aspnet-core/migrations/LY.MicroService.AuthServer.EntityFrameworkCore/DataSeeds/IdentityUserRoleDataSeeder.cs

@ -1,4 +1,6 @@
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using System;
using System.Threading.Tasks;
@ -19,6 +21,8 @@ public class IdentityUserRoleDataSeeder : ITransientDependency
public const string AdminPasswordPropertyName = "AdminPassword";
public const string AdminPasswordDefaultValue = "1q2w3E*";
public ILogger<IdentityUserRoleDataSeeder> Logger { protected get; set; }
protected IGuidGenerator GuidGenerator { get; }
protected IIdentityRoleRepository RoleRepository { get; }
protected IIdentityUserRepository UserRepository { get; }
@ -43,12 +47,19 @@ public class IdentityUserRoleDataSeeder : ITransientDependency
UserManager = userManager;
RoleManager = roleManager;
IdentityOptions = identityOptions;
Logger = NullLogger<IdentityUserRoleDataSeeder>.Instance;
}
public virtual async Task SeedAsync(DataSeedContext context)
{
Logger.LogInformation("Seeding the admin user roles...");
await SeedAdminUserAsync(context);
Logger.LogInformation("Seeding the default roles...");
await SeedDefaultRoleAsync(context);
Logger.LogInformation("Seeding user roles completed.");
}
private async Task SeedAdminUserAsync(DataSeedContext context)
@ -59,8 +70,13 @@ public class IdentityUserRoleDataSeeder : ITransientDependency
var adminUserName = context?[AdminUserNamePropertyName] as string ?? AdminUserNameDefaultValue;
Guid adminRoleId;
Logger.LogInformation("Check admin role {adminRoleName} exists.", adminRoleName);
if (!await RoleManager.RoleExistsAsync(adminRoleName))
{
Logger.LogInformation("Create new role {adminRoleName}.", adminRoleName);
adminRoleId = GuidGenerator.Create();
var adminRole = new IdentityRole(
adminRoleId,
@ -87,9 +103,13 @@ public class IdentityUserRoleDataSeeder : ITransientDependency
var adminEmailAddress = context?[AdminEmailPropertyName] as string ?? AdminEmailDefaultValue;
var adminPassword = context?[AdminPasswordPropertyName] as string ?? AdminPasswordDefaultValue;
Logger.LogInformation("Check admin user {adminUserName} exists.", adminUserName);
var adminUser = await UserManager.FindByNameAsync(adminUserName);
if (adminUser == null)
{
Logger.LogInformation("Create new user {adminUserName}.", adminUserName);
adminUser = new IdentityUser(
adminUserId,
adminUserName,
@ -100,6 +120,8 @@ public class IdentityUserRoleDataSeeder : ITransientDependency
// 创建租户管理用户
(await UserManager.CreateAsync(adminUser)).CheckErrors();
Logger.LogInformation("Add user {adminUserName} password.", adminUserName);
(await UserManager.AddPasswordAsync(adminUser, adminPassword)).CheckErrors();
}
}
@ -107,8 +129,10 @@ public class IdentityUserRoleDataSeeder : ITransientDependency
private async Task SeedDefaultRoleAsync(DataSeedContext context)
{
const string defaultRoleName = "Users";
if (await RoleManager.FindByNameAsync(defaultRoleName) != null)
Logger.LogInformation("Check Role {defaultRoleName} exists.", defaultRoleName);
if (!await RoleManager.RoleExistsAsync(defaultRoleName))
{
Logger.LogInformation("Create new role {defaultRoleName}.", defaultRoleName);
var roleId = GuidGenerator.Create();
var defaultRole = new IdentityRole(
roleId,

6
aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/BackendAdminDbMigratorModule.cs

@ -1,12 +1,11 @@
using LINGYUN.Abp.Auditing;
using LINGYUN.Abp.BlobManagement;
using LINGYUN.Abp.CachingManagement;
using LINGYUN.Abp.Identity;
using LINGYUN.Abp.IdentityServer;
using LINGYUN.Abp.LocalizationManagement;
using LINGYUN.Abp.MessageService;
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.OpenIddict;
using LINGYUN.Abp.OssManagement;
using LINGYUN.Abp.SettingManagement;
using LINGYUN.Abp.TaskManagement;
using LINGYUN.Abp.TextTemplating;
@ -30,10 +29,9 @@ namespace LY.MicroService.BackendAdmin.DbMigrator;
typeof(AbpAuditingApplicationContractsModule),
typeof(AbpTextTemplatingApplicationContractsModule),
typeof(AbpIdentityApplicationContractsModule),
typeof(AbpIdentityServerApplicationContractsModule),
typeof(AbpOpenIddictApplicationContractsModule),
typeof(PlatformApplicationContractModule),
typeof(AbpOssManagementApplicationContractsModule),
typeof(AbpBlobManagementApplicationContractsModule),
typeof(AbpNotificationsApplicationContractsModule),
typeof(AbpMessageServiceApplicationContractsModule),
typeof(TaskManagementApplicationContractsModule),

3
aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/LY.MicroService.BackendAdmin.DbMigrator.csproj

@ -38,9 +38,8 @@
<ProjectReference Include="..\..\modules\realtime-notifications\LINGYUN.Abp.Notifications.Application.Contracts\LINGYUN.Abp.Notifications.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\realtime-message\LINGYUN.Abp.MessageService.Application.Contracts\LINGYUN.Abp.MessageService.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\platform\LINGYUN.Platform.Application.Contracts\LINGYUN.Platform.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\oss-management\LINGYUN.Abp.OssManagement.Application.Contracts\LINGYUN.Abp.OssManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\blob-management\LINGYUN.Abp.BlobManagement.Application.Contracts\LINGYUN.Abp.BlobManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\localization-management\LINGYUN.Abp.LocalizationManagement.Application.Contracts\LINGYUN.Abp.LocalizationManagement.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.Application.Contracts\LINGYUN.Abp.IdentityServer.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.Application.Contracts\LINGYUN.Abp.Identity.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\openiddict\LINGYUN.Abp.OpenIddict.Application.Contracts\LINGYUN.Abp.OpenIddict.Application.Contracts.csproj" />
<ProjectReference Include="..\..\framework\settings\LINGYUN.Abp.SettingManagement.Application.Contracts\LINGYUN.Abp.SettingManagement.Application.Contracts.csproj" />

2
aspnet-core/migrations/LY.MicroService.BackendAdmin.DbMigrator/appsettings.json

@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=abp;User Id=root;Password=123456;SslMode=None"
"Default": "Server=localhost;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",

10
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminDataSeeder.cs → aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/AdminServiceDataSeeder.cs

@ -1,6 +1,5 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Authorization.Permissions;
@ -11,14 +10,14 @@ using Volo.Abp.PermissionManagement;
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore;
public class BackendAdminDataSeeder : ITransientDependency
public class AdminServiceDataSeeder : ITransientDependency
{
protected ILogger<BackendAdminDataSeeder> Logger { get; }
protected ILogger<AdminServiceDataSeeder> Logger { get; }
protected ICurrentTenant CurrentTenant { get; }
protected IPermissionDefinitionManager PermissionDefinitionManager { get; }
protected IPermissionDataSeeder PermissionDataSeeder { get; }
public BackendAdminDataSeeder(
public AdminServiceDataSeeder(
IPermissionDefinitionManager permissionDefinitionManager,
IPermissionDataSeeder permissionDataSeeder,
ICurrentTenant currentTenant)
@ -27,7 +26,7 @@ public class BackendAdminDataSeeder : ITransientDependency
PermissionDataSeeder = permissionDataSeeder;
CurrentTenant = currentTenant;
Logger = NullLogger<BackendAdminDataSeeder>.Instance;
Logger = NullLogger<AdminServiceDataSeeder>.Instance;
}
public virtual async Task SeedAsync(DataSeedContext context)
@ -59,3 +58,4 @@ public class BackendAdminDataSeeder : ITransientDependency
Logger.LogInformation("Seed default role permissions completed.");
}
}

4
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminDbMigrationEventHandler.cs

@ -11,7 +11,7 @@ namespace LY.MicroService.BackendAdmin.EntityFrameworkCore;
public class BackendAdminDbMigrationEventHandler : EfCoreDatabaseMigrationEventHandlerBase<BackendAdminMigrationsDbContext>
{
protected BackendAdminDataSeeder DataSeeder { get; }
protected AdminServiceDataSeeder DataSeeder { get; }
public BackendAdminDbMigrationEventHandler(
ICurrentTenant currentTenant,
@ -20,7 +20,7 @@ public class BackendAdminDbMigrationEventHandler : EfCoreDatabaseMigrationEventH
IAbpDistributedLock abpDistributedLock,
IDistributedEventBus distributedEventBus,
ILoggerFactory loggerFactory,
BackendAdminDataSeeder dataSeeder)
AdminServiceDataSeeder dataSeeder)
: base(
ConnectionStringNameAttribute.GetConnStringName<BackendAdminMigrationsDbContext>(),
currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory)

28
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminDbMigrationService.cs

@ -1,8 +1,6 @@
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.Saas.Tenants;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@ -15,14 +13,10 @@ namespace LY.MicroService.BackendAdmin.EntityFrameworkCore;
public class BackendAdminDbMigrationService : EfCoreRuntimeDbMigratorBase<BackendAdminMigrationsDbContext>, ITransientDependency
{
protected IDataSeeder DataSeeder { get; }
protected IDbSchemaMigrator DbSchemaMigrator { get; }
protected ITenantRepository TenantRepository { get; }
protected AdminServiceDataSeeder DataSeeder { get; }
public BackendAdminDbMigrationService(
IDataSeeder dataSeeder,
IDbSchemaMigrator dbSchemaMigrator,
ITenantRepository tenantRepository,
AdminServiceDataSeeder dataSeeder,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IServiceProvider serviceProvider,
@ -34,25 +28,11 @@ public class BackendAdminDbMigrationService : EfCoreRuntimeDbMigratorBase<Backen
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory)
{
DataSeeder = dataSeeder;
DbSchemaMigrator = dbSchemaMigrator;
TenantRepository = tenantRepository;
}
protected async override Task LockAndApplyDatabaseMigrationsAsync()
{
await base.LockAndApplyDatabaseMigrationsAsync();
var tenants = await TenantRepository.GetListAsync();
foreach (var tenant in tenants.Where(x => x.IsActive))
{
await LockAndApplyDatabaseWithTenantMigrationsAsync(tenant.Id);
}
}
protected async override Task SeedAsync()
{
Logger.LogInformation($"Executing {(!CurrentTenant.IsAvailable ? "host" : CurrentTenant.Name ?? CurrentTenant.GetId().ToString())} database seed...");
await DataSeeder.SeedAsync(CurrentTenant.Id);
// DbMigrator迁移数据种子
await DataSeeder.SeedAsync(new DataSeedContext());
}
}

2
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminMigrationsEntityFrameworkCoreModule.cs

@ -35,7 +35,7 @@ public class BackendAdminMigrationsEntityFrameworkCoreModule : AbpModule
mysql =>
{
// see: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/1960
mysql.UseParameterizedCollectionMode(ParameterTranslationMode.Parameter);
mysql.UseParameterizedCollectionMode(ParameterTranslationMode.Constant);
});
});
}

5
aspnet-core/migrations/LY.MicroService.IdentityServer.DbMigrator/appsettings.json

@ -1,9 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Platform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Identity": "Server=127.0.0.1;Database=IdentityServer-V70;User Id=root;Password=123456;SslMode=None",
"Realtime": "Server=127.0.0.1;Database=Messages-V70;User Id=root;Password=123456;SslMode=None"
"Default": "Server=127.0.0.1;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"IdentityServer": {
"Clients": {

1
aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/LY.MicroService.LocalizationManagement.DbMigrator.csproj

@ -22,7 +22,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" />
</ItemGroup>
<ItemGroup>

5
aspnet-core/migrations/LY.MicroService.LocalizationManagement.DbMigrator/appsettings.json

@ -1,9 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Platform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Identity": "Server=127.0.0.1;Database=AuthServer-V70;User Id=root;Password=123456;SslMode=None",
"Realtime": "Server=127.0.0.1;Database=Messages-V70;User Id=root;Password=123456;SslMode=None"
"Default": "Server=localhost;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",

31
aspnet-core/migrations/LY.MicroService.LocalizationManagement.EntityFrameworkCore/LocalizationManagementDbMigrationService.cs

@ -1,9 +1,6 @@
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.Saas.Tenants;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.DistributedLocking;
@ -15,14 +12,7 @@ namespace LY.MicroService.LocalizationManagement.EntityFrameworkCore;
public class LocalizationManagementDbMigrationService : EfCoreRuntimeDbMigratorBase<LocalizationManagementMigrationsDbContext>, ITransientDependency
{
protected IDataSeeder DataSeeder { get; }
protected IDbSchemaMigrator DbSchemaMigrator { get; }
protected ITenantRepository TenantRepository { get; }
public LocalizationManagementDbMigrationService(
IDataSeeder dataSeeder,
IDbSchemaMigrator dbSchemaMigrator,
ITenantRepository tenantRepository,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IServiceProvider serviceProvider,
@ -33,26 +23,5 @@ public class LocalizationManagementDbMigrationService : EfCoreRuntimeDbMigratorB
ConnectionStringNameAttribute.GetConnStringName<LocalizationManagementMigrationsDbContext>(),
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory)
{
DataSeeder = dataSeeder;
DbSchemaMigrator = dbSchemaMigrator;
TenantRepository = tenantRepository;
}
protected async override Task LockAndApplyDatabaseMigrationsAsync()
{
await base.LockAndApplyDatabaseMigrationsAsync();
var tenants = await TenantRepository.GetListAsync();
foreach (var tenant in tenants.Where(x => x.IsActive))
{
await LockAndApplyDatabaseWithTenantMigrationsAsync(tenant.Id);
}
}
protected async override Task SeedAsync()
{
Logger.LogInformation($"Executing {(!CurrentTenant.IsAvailable ? "host" : CurrentTenant.Name ?? CurrentTenant.GetId().ToString())} database seed...");
await DataSeeder.SeedAsync(CurrentTenant.Id);
}
}

1
aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/LY.MicroService.Platform.DbMigrator.csproj

@ -23,7 +23,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" />
</ItemGroup>
<ItemGroup>

2
aspnet-core/migrations/LY.MicroService.Platform.DbMigrator/appsettings.json

@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=abp;User Id=root;Password=123456;SslMode=None"
"Default": "Server=localhost;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",

1501
aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20260424033808_Add-Blob-Management-Module.Designer.cs

File diff suppressed because it is too large

116
aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/20260424033808_Add-Blob-Management-Module.cs

@ -0,0 +1,116 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations
{
/// <inheritdoc />
public partial class AddBlobManagementModule : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AbpBlobContainers",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Provider = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ExtraProperties = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_AbpBlobContainers", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "AbpBlobs",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
ContainerId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
Type = table.Column<int>(type: "int", nullable: false),
ContentType = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true)
.Annotation("MySql:CharSet", "utf8mb4"),
Size = table.Column<long>(type: "bigint", nullable: false),
ExpirationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
Provider = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
FullName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
DownloadCount = table.Column<long>(type: "bigint", nullable: false),
ExtraProperties = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
.Annotation("MySql:CharSet", "utf8mb4"),
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false),
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true),
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_AbpBlobs", x => x.Id);
table.ForeignKey(
name: "FK_AbpBlobs_AbpBlobContainers_ContainerId",
column: x => x.ContainerId,
principalTable: "AbpBlobContainers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AbpBlobs_AbpBlobs_ParentId",
column: x => x.ParentId,
principalTable: "AbpBlobs",
principalColumn: "Id");
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AbpBlobContainers_TenantId_Name",
table: "AbpBlobContainers",
columns: new[] { "TenantId", "Name" });
migrationBuilder.CreateIndex(
name: "IX_AbpBlobs_ContainerId",
table: "AbpBlobs",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_AbpBlobs_ParentId",
table: "AbpBlobs",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_AbpBlobs_TenantId_ContainerId_FullName",
table: "AbpBlobs",
columns: new[] { "TenantId", "ContainerId", "FullName" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AbpBlobs");
migrationBuilder.DropTable(
name: "AbpBlobContainers");
}
}
}

161
aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/Migrations/PlatformMigrationsDbContextModelSnapshot.cs

@ -19,11 +19,152 @@ namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("ProductVersion", "9.0.0")
.HasAnnotation("ProductVersion", "10.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
modelBuilder.Entity("LINGYUN.Abp.BlobManagement.Blob", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<Guid>("ContainerId")
.HasColumnType("char(36)");
b.Property<string>("ContentType")
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<long>("DownloadCount")
.HasColumnType("bigint");
b.Property<DateTime?>("ExpirationTime")
.HasColumnType("datetime(6)");
b.Property<string>("ExtraProperties")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<string>("FullName")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("varchar(256)");
b.Property<Guid?>("ParentId")
.HasColumnType("char(36)");
b.Property<string>("Provider")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<long>("Size")
.HasColumnType("bigint");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.Property<int>("Type")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ContainerId");
b.HasIndex("ParentId");
b.HasIndex("TenantId", "ContainerId", "FullName");
b.ToTable("AbpBlobs", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.BlobManagement.BlobContainer", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime(6)")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("char(36)")
.HasColumnName("CreatorId");
b.Property<string>("ExtraProperties")
.IsRequired()
.HasColumnType("longtext")
.HasColumnName("ExtraProperties");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime(6)")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("char(36)")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("varchar(128)");
b.Property<string>("Provider")
.IsRequired()
.HasMaxLength(64)
.HasColumnType("varchar(64)");
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)")
.HasColumnName("TenantId");
b.HasKey("Id");
b.HasIndex("TenantId", "Name");
b.ToTable("AbpBlobContainers", (string)null);
});
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b =>
{
b.Property<Guid>("Id")
@ -1254,6 +1395,19 @@ namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations
b.ToTable("AppPlatformEnterprises", (string)null);
});
modelBuilder.Entity("LINGYUN.Abp.BlobManagement.Blob", b =>
{
b.HasOne("LINGYUN.Abp.BlobManagement.BlobContainer", null)
.WithMany()
.HasForeignKey("ContainerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("LINGYUN.Abp.BlobManagement.Blob", null)
.WithMany("Blobs")
.HasForeignKey("ParentId");
});
modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b =>
{
b.HasOne("LINGYUN.Platform.Datas.Data", null)
@ -1310,6 +1464,11 @@ namespace LY.MicroService.Platform.EntityFrameworkCore.Migrations
b.Navigation("Package");
});
modelBuilder.Entity("LINGYUN.Abp.BlobManagement.Blob", b =>
{
b.Navigation("Blobs");
});
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b =>
{
b.Navigation("Items");

28
aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/PlatformDbMigrationService.cs

@ -1,8 +1,6 @@
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.Saas.Tenants;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
@ -15,14 +13,10 @@ namespace LY.MicroService.Platform.EntityFrameworkCore;
public class PlatformDbMigrationService : EfCoreRuntimeDbMigratorBase<PlatformMigrationsDbContext>, ITransientDependency
{
protected IDataSeeder DataSeeder { get; }
protected IDbSchemaMigrator DbSchemaMigrator { get; }
protected ITenantRepository TenantRepository { get; }
protected PlatformServiceDataSeeder DataSeeder { get; }
public PlatformDbMigrationService(
IDataSeeder dataSeeder,
IDbSchemaMigrator dbSchemaMigrator,
ITenantRepository tenantRepository,
PlatformServiceDataSeeder dataSeeder,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IServiceProvider serviceProvider,
@ -34,25 +28,11 @@ public class PlatformDbMigrationService : EfCoreRuntimeDbMigratorBase<PlatformMi
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory)
{
DataSeeder = dataSeeder;
DbSchemaMigrator = dbSchemaMigrator;
TenantRepository = tenantRepository;
}
protected async override Task LockAndApplyDatabaseMigrationsAsync()
{
await base.LockAndApplyDatabaseMigrationsAsync();
var tenants = await TenantRepository.GetListAsync();
foreach (var tenant in tenants.Where(x => x.IsActive))
{
await LockAndApplyDatabaseWithTenantMigrationsAsync(tenant.Id);
}
}
protected async override Task SeedAsync()
{
Logger.LogInformation($"Executing {(!CurrentTenant.IsAvailable ? "host" : CurrentTenant.Name ?? CurrentTenant.GetId().ToString())} database seed...");
await DataSeeder.SeedAsync(CurrentTenant.Id);
// DbMigrator迁移数据种子
await DataSeeder.SeedAsync(new DataSeedContext());
}
}

4
aspnet-core/migrations/LY.MicroService.Platform.EntityFrameworkCore/PlatformMigrationsDbContext.cs

@ -1,4 +1,5 @@
using LINGYUN.Platform.EntityFrameworkCore;
using LINGYUN.Abp.BlobManagement.EntityFrameworkCore;
using LINGYUN.Platform.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
@ -19,5 +20,6 @@ public class PlatformMigrationsDbContext : AbpDbContext<PlatformMigrationsDbCont
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigurePlatform();
modelBuilder.ConfigureBlobManagement();
}
}

1
aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/LY.MicroService.RealtimeMessage.DbMigrator.csproj

@ -22,7 +22,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" />
</ItemGroup>
<ItemGroup>

5
aspnet-core/migrations/LY.MicroService.RealtimeMessage.DbMigrator/appsettings.json

@ -1,9 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Platform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Identity": "Server=127.0.0.1;Database=AuthServer-V70;User Id=root;Password=123456;SslMode=None",
"Realtime": "Server=127.0.0.1;Database=Messages-V70;User Id=root;Password=123456;SslMode=None"
"Default": "Server=localhost;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",

31
aspnet-core/migrations/LY.MicroService.RealtimeMessage.EntityFrameworkCore/RealtimeMessageDbMigrationService.cs

@ -1,9 +1,6 @@
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.Saas.Tenants;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.DistributedLocking;
@ -15,14 +12,7 @@ namespace LY.MicroService.RealtimeMessage.EntityFrameworkCore;
public class RealtimeMessageDbMigrationService : EfCoreRuntimeDbMigratorBase<RealtimeMessageMigrationsDbContext>, ITransientDependency
{
protected IDataSeeder DataSeeder { get; }
protected IDbSchemaMigrator DbSchemaMigrator { get; }
protected ITenantRepository TenantRepository { get; }
public RealtimeMessageDbMigrationService(
IDataSeeder dataSeeder,
IDbSchemaMigrator dbSchemaMigrator,
ITenantRepository tenantRepository,
ICurrentTenant currentTenant,
IUnitOfWorkManager unitOfWorkManager,
IServiceProvider serviceProvider,
@ -33,26 +23,5 @@ public class RealtimeMessageDbMigrationService : EfCoreRuntimeDbMigratorBase<Rea
ConnectionStringNameAttribute.GetConnStringName<RealtimeMessageMigrationsDbContext>(),
unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory)
{
DataSeeder = dataSeeder;
DbSchemaMigrator = dbSchemaMigrator;
TenantRepository = tenantRepository;
}
protected async override Task LockAndApplyDatabaseMigrationsAsync()
{
await base.LockAndApplyDatabaseMigrationsAsync();
var tenants = await TenantRepository.GetListAsync();
foreach (var tenant in tenants.Where(x => x.IsActive))
{
await LockAndApplyDatabaseWithTenantMigrationsAsync(tenant.Id);
}
}
protected async override Task SeedAsync()
{
Logger.LogInformation($"Executing {(!CurrentTenant.IsAvailable ? "host" : CurrentTenant.Name ?? CurrentTenant.GetId().ToString())} database seed...");
await DataSeeder.SeedAsync(CurrentTenant.Id);
}
}

1
aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/LY.MicroService.TaskManagement.DbMigrator.csproj

@ -19,7 +19,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" />
</ItemGroup>
<ItemGroup>

2
aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.PostgreSql.json

@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer"
"Default": "Host=localhost;Database=abp;Username=postgres;Password=123456;SslMode=Prefer"
}
}

5
aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.json

@ -1,9 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Platform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Identity": "Server=127.0.0.1;Database=AuthServer-V70;User Id=root;Password=123456;SslMode=None",
"Realtime": "Server=127.0.0.1;Database=Messages-V70;User Id=root;Password=123456;SslMode=None"
"Default": "Server=localhost;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",

8
aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/TaskManagementDbMigrationEventHandler.cs

@ -15,7 +15,7 @@ public class TaskManagementDbMigrationEventHandler :
EfCoreDatabaseMigrationEventHandlerBase<TaskManagementMigrationsDbContext>,
IDistributedEventHandler<EntityDeletedEto<TenantEto>>
{
protected TaskManagementDataSeeder DataSeeder { get; }
protected TaskServiceDataSeeder DataSeeder { get; }
public TaskManagementDbMigrationEventHandler(
ICurrentTenant currentTenant,
@ -24,8 +24,10 @@ public class TaskManagementDbMigrationEventHandler :
IAbpDistributedLock abpDistributedLock,
IDistributedEventBus distributedEventBus,
ILoggerFactory loggerFactory,
TaskManagementDataSeeder dataSeeder)
: base("TaskManagementDbMigrator", currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory)
TaskServiceDataSeeder dataSeeder)
: base(
ConnectionStringNameAttribute.GetConnStringName<TaskManagementMigrationsDbContext>(),
currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory)
{
DataSeeder = dataSeeder;
}

4
aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/TaskManagementDataSeeder.cs → aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/TaskServiceDataSeeder.cs

@ -10,14 +10,14 @@ using Volo.Abp.MultiTenancy;
namespace LY.MicroService.TaskManagement.EntityFrameworkCore;
public class TaskManagementDataSeeder : ITransientDependency
public class TaskServiceDataSeeder : ITransientDependency
{
protected AbpBackgroundTasksOptions Options { get; }
protected IJobStore JobStore { get; }
protected IJobScheduler JobScheduler { get; }
protected ICurrentTenant CurrentTenant { get; }
public TaskManagementDataSeeder(
public TaskServiceDataSeeder(
IOptions<AbpBackgroundTasksOptions> options,
IJobStore jobStore,
IJobScheduler jobScheduler,

1
aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/LY.MicroService.WebhooksManagement.DbMigrator.csproj

@ -20,7 +20,6 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" />
</ItemGroup>
<ItemGroup>

5
aspnet-core/migrations/LY.MicroService.WebhooksManagement.DbMigrator/appsettings.json

@ -1,9 +1,6 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Platform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"Identity": "Server=127.0.0.1;Database=AuthServer-V70;User Id=root;Password=123456;SslMode=None",
"Realtime": "Server=127.0.0.1;Database=Messages-V70;User Id=root;Password=123456;SslMode=None"
"Default": "Server=localhost;Database=abp;User Id=root;Password=123456;SslMode=None"
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",

5
aspnet-core/migrations/LY.MicroService.WebhooksManagement.EntityFrameworkCore/WebhooksManagementDbMigrationEventHandler.cs

@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using Volo.Abp.Data;
using Volo.Abp.DistributedLocking;
using Volo.Abp.EntityFrameworkCore.Migrations;
using Volo.Abp.EventBus.Distributed;
@ -16,7 +17,9 @@ public class WebhooksManagementDbMigrationEventHandler : EfCoreDatabaseMigration
IAbpDistributedLock abpDistributedLock,
IDistributedEventBus distributedEventBus,
ILoggerFactory loggerFactory)
: base("WebhooksManagementDbMigrator", currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory)
: base(
ConnectionStringNameAttribute.GetConnStringName<WebhooksManagementMigrationsDbContext>(),
currentTenant, unitOfWorkManager, tenantStore, abpDistributedLock, distributedEventBus, loggerFactory)
{
}
}

2
aspnet-core/modules/gdpr/LINGYUN.Abp.Gdpr.Application/LINGYUN/Abp/Gdpr/GdprRequestAppService.cs

@ -21,7 +21,7 @@ namespace LINGYUN.Abp.Gdpr;
[Authorize]
public class GdprRequestAppService(
IJsonSerializer jsonSerializer,
IExporterProvider exporterProvider,
IExcelExporterProvider exporterProvider,
IOptions<AbpGdprOptions> gdprOptions,
IDistributedEventBus distributedEventBus,
IDistributedCache<GdprRequestCacheItem> gdprRequestCache,

2
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Application/LINGYUN/Abp/Notifications/AbpNotificationsApplicationMappers.cs

@ -43,9 +43,11 @@ public partial class NotificationSendRecordInfoToNotificationSendRecordDtoMapper
_userNotificationInfoMapper = userNotificationInfoMapper;
}
[MapperIgnoreTarget(nameof(NotificationSendRecordDto.Notification))]
[MapProperty(nameof(NotificationSendRecordInfo.Id), nameof(NotificationSendRecordDto.Id))]
public override partial NotificationSendRecordDto Map(NotificationSendRecordInfo source);
[MapperIgnoreTarget(nameof(NotificationSendRecordDto.Notification))]
[MapProperty(nameof(NotificationSendRecordInfo.Id), nameof(NotificationSendRecordDto.Id))]
public override partial void Map(NotificationSendRecordInfo source, NotificationSendRecordDto destination);

2
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.Core/LINGYUN/Abp/Notifications/NotificationPublishContext.cs

@ -26,7 +26,7 @@ public class NotificationPublishContext
Users = users;
}
public void Cancel(string reason, Exception exception = null)
public void Cancel(string reason, Exception? exception = null)
{
Reason = reason;
Exception = exception;

Loading…
Cancel
Save