Browse Source

feat(single): Optimize single application projects

- 增加多数据库启动配置项
- 调整多数据库模式数据库迁移
- 修复部分数据库迁移脚本
- 增加缺少的版本升级数据库迁移
- 增加Quartz的PostgreSql初始化模块
- 调整单体服务启动文档
pull/1397/head
colin 2 weeks ago
parent
commit
368e7e9647
  1. 3
      Directory.Packages.props
  2. 9
      aspnet-core/LINGYUN.MicroService.SingleProject.sln
  3. 11
      aspnet-core/LINGYUN.MicroService.TaskManagement.sln
  4. 18
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/LY.MicroService.Applications.Single.DbMigrator.csproj
  5. 16
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Program.cs
  6. 28
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Properties/launchSettings.json
  7. 16
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/SingleDbMigratorModule.cs
  8. 2
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.MySql.json
  9. 2
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.SqlServer.json
  10. 10
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json
  11. 5470
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20251205024625_Upgrade-Abp-Framework-To-9.3.6.Designer.cs
  12. 43
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20251205024625_Upgrade-Abp-Framework-To-9.3.6.cs
  13. 57
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs
  14. 2
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj
  15. 5470
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/Migrations/20251204080204_Upgrade-Abp-Framework-To-9.3.6.Designer.cs
  16. 1250
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/Migrations/20251204080204_Upgrade-Abp-Framework-To-9.3.6.cs
  17. 2116
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/Migrations/SingleMigrationsDbContextModelSnapshot.cs
  18. 7
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsDbContextFactory.cs
  19. 53
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsEntityFrameworkCorePostgreSqlModule.cs
  20. 5475
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/Migrations/20251205024538_Upgrade-Abp-Framework-To-9.3.6.Designer.cs
  21. 37
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/Migrations/20251205024538_Upgrade-Abp-Framework-To-9.3.6.cs
  22. 30
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/Migrations/SingleMigrationsDbContextModelSnapshot.cs
  23. 51
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/SingleMigrationsEntityFrameworkCoreSqlServerModule.cs
  24. 2
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/DataSeeder/ClientDataSeederContributor.cs
  25. 2
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleDbMigrationService.cs
  26. 204
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleMigrationsDbContext.cs
  27. 6
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleMigrationsEntityFrameworkCoreModule.cs
  28. 5
      aspnet-core/migrations/LY.MicroService.TaskManagement.DbMigrator/appsettings.PostgreSql.json
  29. 1
      aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/LY.MicroService.TaskManagement.EntityFrameworkCore.csproj
  30. 2
      aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/TaskManagementMigrationsEntityFrameworkCoreModule.cs
  31. 2
      aspnet-core/migrations/Migrate.ps1
  32. 5
      aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/EntityFrameworkCore/DemoDbContext.cs
  33. 15
      aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/EntityFrameworkCore/IDemoDbContext.cs
  34. 15
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN/Abp/Elsa/EntityFrameworkCore/MySql/AbpElsaEntityFrameworkCoreMySqlModule.cs
  35. 36
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN/Abp/Elsa/EntityFrameworkCore/MySql/Migrations/Initial.sql
  36. 1
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN/Abp/Elsa/EntityFrameworkCore/MySql/Migrations/MySqlElsaDataBaseInstaller.cs
  37. 5
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql.csproj
  38. 24
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN/Abp/Elsa/EntityFrameworkCore/PostgreSql/AbpElsaEntityFrameworkCorePostgreSqlModule.cs
  39. 291
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN/Abp/Elsa/EntityFrameworkCore/PostgreSql/Migrations/Initial.sql
  40. 143
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN/Abp/Elsa/EntityFrameworkCore/PostgreSql/Migrations/PostgreSqlElsaDataBaseInstaller.cs
  41. 15
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer/LINGYUN/Abp/Elsa/EntityFrameworkCore/SqlServer/AbpElsaEntityFrameworkCoreSqlServerModule.cs
  42. 315
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer/LINGYUN/Abp/Elsa/EntityFrameworkCore/SqlServer/Migrations/Initial.sql
  43. 32
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer/LINGYUN/Abp/Elsa/EntityFrameworkCore/SqlServer/Migrations/SqlServerElsaDataBaseInstaller.cs
  44. 13
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN/Abp/Elsa/EntityFrameworkCore/AbpElsaEntityFrameworkCoreModule.cs
  45. 5
      aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN/Abp/Elsa/EntityFrameworkCore/Migrations/AbpElsaDataBaseInstallerOptions.cs
  46. 6
      aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs
  47. 5
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDefinitionDbContext.cs
  48. 3
      aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs
  49. 3
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/AbpQuartzMySqlInstallerModule.cs
  50. 7
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/MySqlQuartzSqlInstaller.cs
  51. 3
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/FodyWeavers.xml
  52. 30
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/FodyWeavers.xsd
  53. 30
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN.Abp.Quartz.PostgresSqlInstaller.csproj
  54. 22
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN/Abp/Quartz/PostgresSqlInstaller/AbpQuartzPostgresSqlInstallerModule.cs
  55. 189
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN/Abp/Quartz/PostgresSqlInstaller/PostgresSqlQuartzSqlInstaller.cs
  56. 180
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN/Abp/Quartz/PostgresSqlInstaller/Scripts/Initial.sql
  57. 1
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN.Abp.Quartz.SqlInstaller.csproj
  58. 55
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/AbpQuartzSqlInstallerModule.cs
  59. 2
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/IQuartzSqlInstaller.cs
  60. 3
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/AbpQuartzSqlServerInstallerModule.cs
  61. 7
      aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/SqlServerQuartzSqlInstaller.cs
  62. 8
      aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs
  63. 3
      aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj
  64. 13
      aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs
  65. 15
      aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs
  66. 9
      aspnet-core/services/LY.MicroService.Applications.Single/Program.cs
  67. 10
      aspnet-core/services/LY.MicroService.Applications.Single/Properties/launchSettings.json
  68. 63
      aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.MySql.json
  69. 63
      aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.PostgreSql.json
  70. 63
      aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.SqlServer.json
  71. 45
      aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.json
  72. 23
      aspnet-core/services/LY.MicroService.Applications.Single/appsettings.SqlServer.json
  73. 1
      aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj
  74. 1
      aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs
  75. 2
      aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Properties/launchSettings.json
  76. 2
      aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs
  77. 10
      aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json
  78. 36
      docs/startup-aio-readme.md

3
Directory.Packages.props

@ -222,6 +222,7 @@
<PackageVersion Include="DotNetCore.CAP.Dashboard" Version="$(DotNetCoreCAPPackageVersion)" />
<PackageVersion Include="DotNetCore.CAP.MySql" Version="$(DotNetCoreCAPPackageVersion)" />
<PackageVersion Include="DotNetCore.CAP.SqlServer" Version="$(DotNetCoreCAPPackageVersion)" />
<PackageVersion Include="DotNetCore.CAP.PostgreSql" Version="$(DotNetCoreCAPPackageVersion)" />
<PackageVersion Include="DotNetCore.CAP.OpenTelemetry" Version="$(DotNetCoreCAPPackageVersion)" />
<PackageVersion Include="DotNetCore.CAP.RabbitMQ" Version="$(DotNetCoreCAPPackageVersion)" />
<PackageVersion Include="DotNetCore.CAP.InMemoryStorage" Version="$(DotNetCoreCAPPackageVersion)" />
@ -264,7 +265,7 @@
<ItemGroup>
<PackageVersion Include="MySqlConnector" Version="2.4.0" />
<PackageVersion Include="Oracle.ManagedDataAccess.Core" Version="23.6.1" />
<PackageVersion Include="Npgsql" Version="9.0.2" />
<PackageVersion Include="Npgsql" Version="9.0.3" />
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.1.6" />
<PackageVersion Include="Microsoft.Data.Sqlite.Core" Version="9.0.5" />
</ItemGroup>

9
aspnet-core/LINGYUN.MicroService.SingleProject.sln

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 18
VisualStudioVersion = 18.0.11205.157 d18.0
VisualStudioVersion = 18.0.11205.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{0B58AA48-665A-443F-A6A8-751FB9629DAF}"
EndProject
@ -700,6 +700,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WeChat.Work.Con
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.WeChat.Work.OA", "framework\wechat\LINGYUN.Abp.WeChat.Work.OA\LINGYUN.Abp.WeChat.Work.OA.csproj", "{AB207B2A-C8E7-977D-98E6-66527CBB2B7F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Quartz.PostgresSqlInstaller", "modules\task-management\LINGYUN.Abp.Quartz.PostgresSqlInstaller\LINGYUN.Abp.Quartz.PostgresSqlInstaller.csproj", "{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -1866,6 +1868,10 @@ Global
{AB207B2A-C8E7-977D-98E6-66527CBB2B7F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AB207B2A-C8E7-977D-98E6-66527CBB2B7F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AB207B2A-C8E7-977D-98E6-66527CBB2B7F}.Release|Any CPU.Build.0 = Release|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -2207,6 +2213,7 @@ Global
{5FA85E8E-3276-43DF-CC93-6A9847905166} = {4F837B81-EA7D-472A-8482-3D5A730DF810}
{C996D147-5B81-49D9-949B-F3BC185B2CD4} = {91867618-0D86-4410-91C6-B1166A9ACDF9}
{AB207B2A-C8E7-977D-98E6-66527CBB2B7F} = {91867618-0D86-4410-91C6-B1166A9ACDF9}
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2} = {91EE5D5B-B6DF-43F1-BC09-1A982719A34B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {711A43C0-A2F8-4E5C-9B9F-F2551E4B3FF1}

11
aspnet-core/LINGYUN.MicroService.TaskManagement.sln

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
# Visual Studio Version 18
VisualStudioVersion = 18.0.11205.157
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "host", "host", "{8DA8A2EE-0B26-487E-A6C4-518906E92B1B}"
EndProject
@ -188,6 +188,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.MultiTenancy.Sa
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Telemetry.OpenTelemetry", "framework\telemetry\LINGYUN.Abp.Telemetry.OpenTelemetry\LINGYUN.Abp.Telemetry.OpenTelemetry.csproj", "{164E4514-4E84-F13A-E24E-2A743753CDB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.Abp.Quartz.PostgresSqlInstaller", "modules\task-management\LINGYUN.Abp.Quartz.PostgresSqlInstaller\LINGYUN.Abp.Quartz.PostgresSqlInstaller.csproj", "{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -486,6 +488,10 @@ Global
{164E4514-4E84-F13A-E24E-2A743753CDB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{164E4514-4E84-F13A-E24E-2A743753CDB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{164E4514-4E84-F13A-E24E-2A743753CDB3}.Release|Any CPU.Build.0 = Release|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -564,6 +570,7 @@ Global
{F58A7141-AC0D-26EC-F22A-DF0DB1BA6955} = {DE7B8B71-635D-4113-AA49-B218D6998CEC}
{E09374FE-6B13-D69E-B171-94C63E6B80E5} = {DE7B8B71-635D-4113-AA49-B218D6998CEC}
{164E4514-4E84-F13A-E24E-2A743753CDB3} = {5A41C31A-B966-418B-B446-5BA1D7E61A62}
{CD7B8501-57B7-6C0E-472F-4E9B894ED6C2} = {385578CC-C0F1-4377-A7A2-682B8F416234}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E1FD1F4C-D344-408B-97CF-B6F1F6D7D293}

18
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/LY.MicroService.Applications.Single.DbMigrator.csproj

@ -33,10 +33,26 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.UI.Navigation.VueVbenAdmin\LINGYUN.Abp.UI.Navigation.VueVbenAdmin.csproj" />
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.UI.Navigation.VueVbenAdmin5\LINGYUN.Abp.UI.Navigation.VueVbenAdmin5.csproj" />
<ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj" />
<ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore.MySql\LY.MicroService.Applications.Single.EntityFrameworkCore.Mysql.csproj" />
<ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer\LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.MySql.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.PostgreSql.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="appsettings.SqlServer.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Properties\launchSettings.json">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>

16
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Program.cs

@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using Elsa.Activities.Compensation;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
@ -31,11 +32,14 @@ public class Program
{
return Host.CreateDefaultBuilder(args)
.AddAppSettingsSecretsJson()
// .ConfigureAppConfiguration((context, builder) =>
// {
// builder.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
// .AddJsonFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
// } )
.ConfigureAppConfiguration((context, builder) =>
{
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if (!dbProvider.IsNullOrWhiteSpace())
{
builder.AddJsonFile($"appsettings.{dbProvider}.json", optional: true);
}
})
.ConfigureLogging((context, logging) => logging.ClearProviders())
.ConfigureServices((hostContext, services) =>
{

28
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/Properties/launchSettings.json

@ -0,0 +1,28 @@
{
"profiles": {
"Single.PostgreSql.Dev": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"APPLICATION_DATABASE_PROVIDER": "PostgreSql"
}
},
"Single.MySql.Dev": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"APPLICATION_DATABASE_PROVIDER": "MySql"
}
},
"Single.SqlServer.Dev": {
"commandName": "Project",
"dotnetRunMessages": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"APPLICATION_DATABASE_PROVIDER": "SqlServer"
}
}
}
}

16
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/SingleDbMigratorModule.cs

@ -1,17 +1,19 @@
using LINGYUN.Abp.UI.Navigation.VueVbenAdmin;
using Microsoft.Extensions.DependencyInjection;
using LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql;
using LINGYUN.Abp.UI.Navigation.VueVbenAdmin5;
using LY.MicroService.Applications.Single.EntityFrameworkCore.MySql;
using LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql;
using LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Autofac;
using Volo.Abp.Modularity;
namespace LY.MicroService.Applications.Single.DbMigrator;
[DependsOn(
typeof(AbpUINavigationVueVbenAdminModule),
// typeof(SingleMigrationsEntityFrameworkCorePostgreSqlModule),
typeof(SingleMigrationsEntityFrameworkCoreMySqlModule),
typeof(AbpAutofacModule)
typeof(AbpAutofacModule),
typeof(AbpUINavigationVueVbenAdmin5Module),
typeof(SingleMigrationsEntityFrameworkCorePostgreSqlModule),
typeof(SingleMigrationsEntityFrameworkCoreSqlServerModule),
typeof(SingleMigrationsEntityFrameworkCoreMySqlModule)
)]
public partial class SingleDbMigratorModule : AbpModule
{

2
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.MySql.json

@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None" //MySql
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None"
}
}

2
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.SqlServer.json

@ -1,5 +1,5 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=yourStrong(!)Password;TrustServerCertificate=True"
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;TrustServerCertificate=True"
}
}

10
aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json

@ -2,10 +2,6 @@
"Clock": {
"Kind": "Local"
},
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None"//MySql
// "Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer"//PostgreSql
},
"StringEncryption": {
"DefaultPassPhrase": "s46c5q55nxpeS8Ra",
"InitVectorBytes": "s83ng0abvd02js84",
@ -21,7 +17,8 @@
"RootUrl": "http://127.0.0.1:40080/"
},
"InternalService": {
"ClientId": "InternalServiceClient"
"ClientId": "InternalServiceClient",
"ClientSecret": "1q2w3E*"
}
}
},
@ -32,7 +29,8 @@
"RootUrl": "http://127.0.0.1:40080/"
},
"InternalService": {
"ClientId": "InternalServiceClient"
"ClientId": "InternalServiceClient",
"ClientSecret": "1q2w3E*"
}
}
},

5470
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20251205024625_Upgrade-Abp-Framework-To-9.3.6.Designer.cs

File diff suppressed because it is too large

43
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20251205024625_Upgrade-Abp-Framework-To-9.3.6.cs

@ -0,0 +1,43 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.MySql.Migrations
{
/// <inheritdoc />
public partial class UpgradeAbpFrameworkTo936 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<Guid>(
name: "EntityId",
table: "Demo_BooksAuths",
type: "char(64)",
maxLength: 64,
nullable: false,
collation: "ascii_general_ci",
oldClrType: typeof(string),
oldType: "char(64)",
oldMaxLength: 64)
.OldAnnotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "EntityId",
table: "Demo_BooksAuths",
type: "char(64)",
maxLength: 64,
nullable: false,
oldClrType: typeof(Guid),
oldType: "char(64)",
oldMaxLength: 64)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
}
}
}

57
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/SingleMigrationsEntityFrameworkCoreMySqlModule.cs

@ -4,8 +4,10 @@ using LINGYUN.Abp.Quartz.MySqlInstaller;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.MySQL;
using Volo.Abp.Guids;
using Volo.Abp.Modularity;
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.MySql;
@ -22,32 +24,47 @@ public class SingleMigrationsEntityFrameworkCoreMySqlModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
PreConfigure<CapOptions>(options =>
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if ("MySql".Equals(dbProvider, StringComparison.InvariantCultureIgnoreCase))
{
if (configuration.GetValue<bool>("CAP:IsEnabled"))
var configuration = context.Services.GetConfiguration();
PreConfigure<CapOptions>(options =>
{
options.UseMySql(
sqlOptions =>
{
configuration.GetSection("CAP:MySql").Bind(sqlOptions);
});
}
});
if (configuration.GetValue<bool>("CAP:IsEnabled"))
{
options.UseMySql(
sqlOptions =>
{
configuration.GetSection("CAP:MySql").Bind(sqlOptions);
});
}
});
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<SingleMigrationsDbContext>();
Configure<AbpDbContextOptions>(options =>
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if ("MySql".Equals(dbProvider, StringComparison.InvariantCultureIgnoreCase))
{
options.UseMySQL(
mysql =>
Configure<AbpDbContextOptions>(options =>
{
options.UseMySQL(
mysql =>
{
// see: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/1960
mysql.TranslateParameterizedCollectionsToConstants();
mysql.MigrationsAssembly(GetType().Assembly);
});
});
Configure<AbpSequentialGuidGeneratorOptions>(options =>
{
if (options.DefaultSequentialGuidType == null)
{
// see: https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/issues/1960
mysql.TranslateParameterizedCollectionsToConstants();
});
});
options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsString;
}
});
}
}
}

2
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj

@ -13,6 +13,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" />
<PackageReference Include="DotNetCore.CAP.PostgreSql" />
</ItemGroup>
<ItemGroup>
@ -21,6 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql\LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.Quartz.PostgresSqlInstaller\LINGYUN.Abp.Quartz.PostgresSqlInstaller.csproj" />
<ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore\LY.MicroService.Applications.Single.EntityFrameworkCore.csproj" />
</ItemGroup>

5470
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/Migrations/20251204080204_Upgrade-Abp-Framework-To-9.3.6.Designer.cs

File diff suppressed because it is too large

1250
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/Migrations/20251204080204_Upgrade-Abp-Framework-To-9.3.6.cs

File diff suppressed because it is too large

2116
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/Migrations/SingleMigrationsDbContextModelSnapshot.cs

File diff suppressed because it is too large

7
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsDbContextFactory.cs

@ -10,6 +10,9 @@ public class SingleMigrationsDbContextFactory : IDesignTimeDbContextFactory<Sing
{
public SingleMigrationsDbContext CreateDbContext(string[] args)
{
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
var configuration = BuildConfiguration();
var connectionString = configuration.GetConnectionString("Default");
@ -26,9 +29,7 @@ public class SingleMigrationsDbContextFactory : IDesignTimeDbContextFactory<Sing
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(),
"../LY.MicroService.Applications.Single.DbMigrator/"))
.AddJsonFile("appsettings.json", optional: false)
.AddJsonFile(
"appsettings.PostgreSql.json",
optional: false);
.AddJsonFile("appsettings.PostgreSql.json", optional: false);
return builder.Build();
}

53
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql/SingleMigrationsEntityFrameworkCorePostgreSqlModule.cs

@ -1,27 +1,66 @@
using LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql;
using DotNetCore.CAP;
using LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql;
using LINGYUN.Abp.Quartz.PostgresSqlInstaller;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.PostgreSql;
using Volo.Abp.Guids;
using Volo.Abp.Modularity;
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql;
[DependsOn(
typeof(AbpEntityFrameworkCorePostgreSqlModule),
typeof(AbpQuartzPostgresSqlInstallerModule),
typeof(AbpElsaEntityFrameworkCorePostgreSqlModule),
typeof(SingleMigrationsEntityFrameworkCoreModule)
)]
public class SingleMigrationsEntityFrameworkCorePostgreSqlModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
public override void PreConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<SingleMigrationsDbContext>();
Configure<AbpDbContextOptions>(options =>
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if ("PostgreSql".Equals(dbProvider, StringComparison.InvariantCultureIgnoreCase))
{
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
options.UseNpgsql();
});
var configuration = context.Services.GetConfiguration();
PreConfigure<CapOptions>(options =>
{
if (configuration.GetValue<bool>("CAP:IsEnabled"))
{
options.UsePostgreSql(
sqlOptions =>
{
configuration.GetSection("CAP:PostgreSql").Bind(sqlOptions);
});
}
});
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if ("PostgreSql".Equals(dbProvider, StringComparison.InvariantCultureIgnoreCase))
{
Configure<AbpDbContextOptions>(options =>
{
options.UseNpgsql(npgsql => npgsql.MigrationsAssembly(GetType().Assembly));
});
Configure<AbpSequentialGuidGeneratorOptions>(options =>
{
if (options.DefaultSequentialGuidType == null)
{
options.DefaultSequentialGuidType = SequentialGuidType.SequentialAsString;
}
});
}
}
}

5475
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/Migrations/20251205024538_Upgrade-Abp-Framework-To-9.3.6.Designer.cs

File diff suppressed because it is too large

37
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/Migrations/20251205024538_Upgrade-Abp-Framework-To-9.3.6.cs

@ -0,0 +1,37 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer.Migrations
{
/// <inheritdoc />
public partial class UpgradeAbpFrameworkTo936 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AbpAuditLogExcelFiles",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TenantId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
FileName = table.Column<string>(type: "nvarchar(256)", maxLength: 256, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AbpAuditLogExcelFiles", x => x.Id);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AbpAuditLogExcelFiles");
}
}
}

30
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/Migrations/SingleMigrationsDbContextModelSnapshot.cs

@ -19,7 +19,7 @@ namespace LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer.Migr
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer)
.HasAnnotation("ProductVersion", "9.0.2")
.HasAnnotation("ProductVersion", "9.0.5")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
@ -3633,6 +3633,34 @@ namespace LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer.Migr
b.ToTable("AbpAuditLogActions", (string)null);
});
modelBuilder.Entity("Volo.Abp.AuditLogging.AuditLogExcelFile", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<string>("FileName")
.HasMaxLength(256)
.HasColumnType("nvarchar(256)")
.HasColumnName("FileName");
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier")
.HasColumnName("TenantId");
b.HasKey("Id");
b.ToTable("AbpAuditLogExcelFiles", (string)null);
});
modelBuilder.Entity("Volo.Abp.AuditLogging.EntityChange", b =>
{
b.Property<Guid>("Id")

51
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer/SingleMigrationsEntityFrameworkCoreSqlServerModule.cs

@ -5,8 +5,10 @@ using LINGYUN.Abp.Quartz.SqlServerInstaller;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Quartz;
using System;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Guids;
using Volo.Abp.Modularity;
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer;
@ -23,28 +25,45 @@ public class SingleMigrationsEntityFrameworkCoreSqlServerModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
var configuration = context.Services.GetConfiguration();
PreConfigure<CapOptions>(options =>
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if ("SqlServer".Equals(dbProvider, StringComparison.InvariantCultureIgnoreCase))
{
if (configuration.GetValue<bool>("CAP:IsEnabled"))
var configuration = context.Services.GetConfiguration();
PreConfigure<CapOptions>(options =>
{
options.UseSqlServer(
sqlOptions =>
{
configuration.GetSection("CAP:SqlServer").Bind(sqlOptions);
});
}
});
if (configuration.GetValue<bool>("CAP:IsEnabled"))
{
options.UseSqlServer(
sqlOptions =>
{
configuration.GetSection("CAP:SqlServer").Bind(sqlOptions);
});
}
});
}
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<SingleMigrationsDbContext>();
Configure<AbpDbContextOptions>(options =>
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if ("SqlServer".Equals(dbProvider, StringComparison.InvariantCultureIgnoreCase))
{
options.UseSqlServer();
});
Configure<AbpDbContextOptions>(options =>
{
options.UseSqlServer(sqlServer =>
{
sqlServer.MigrationsAssembly(GetType().Assembly);
});
});
Configure<AbpSequentialGuidGeneratorOptions>(options =>
{
if (options.DefaultSequentialGuidType == null)
{
options.DefaultSequentialGuidType = SequentialGuidType.SequentialAtEnd;
}
});
}
}
}

2
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/DataSeeder/ClientDataSeederContributor.cs

@ -159,7 +159,7 @@ public class ClientDataSeederContributor : IDataSeedContributor, ITransientDepen
await _applicationManager.CreateAsync(new OpenIddictApplicationDescriptor
{
ClientId = internalServiceClientId,
ClientSecret = configurationSection["InternalService:ClientSecret"],
ClientSecret = configurationSection["InternalService:ClientSecret"] ?? "1q2w3e*",
ClientType = OpenIddictConstants.ClientTypes.Confidential,
ConsentType = OpenIddictConstants.ConsentTypes.Explicit,
ApplicationType = OpenIddictConstants.ApplicationTypes.Native,

2
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleDbMigrationService.cs

@ -29,7 +29,7 @@ public class SingleDbMigrationService : EfCoreRuntimeDatabaseMigratorBase<Single
ILoggerFactory loggerFactory,
IDataSeeder dataSeeder,
ITenantRepository tenantRepository)
: base("SingleDbMigrator", unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory)
: base("Platform-V70", unitOfWorkManager, serviceProvider, currentTenant, abpDistributedLock, distributedEventBus, loggerFactory)
{
DataSeeder = dataSeeder;
TenantRepository = tenantRepository;

204
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleMigrationsDbContext.cs

@ -1,28 +1,95 @@
using LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore;
using LINGYUN.Abp.DataProtectionManagement;
using LINGYUN.Abp.DataProtectionManagement.EntityFrameworkCore;
using LINGYUN.Abp.Demo.Authors;
using LINGYUN.Abp.Demo.Books;
using LINGYUN.Abp.Demo.EntityFrameworkCore;
using LINGYUN.Abp.Gdpr;
using LINGYUN.Abp.Gdpr.EntityFrameworkCore;
using LINGYUN.Abp.LocalizationManagement;
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
using LINGYUN.Abp.MessageService.Chat;
using LINGYUN.Abp.MessageService.EntityFrameworkCore;
using LINGYUN.Abp.MessageService.Groups;
using LINGYUN.Abp.Notifications;
using LINGYUN.Abp.Notifications.EntityFrameworkCore;
using LINGYUN.Abp.Saas.Editions;
using LINGYUN.Abp.Saas.EntityFrameworkCore;
using LINGYUN.Abp.Saas.Tenants;
using LINGYUN.Abp.TaskManagement;
using LINGYUN.Abp.TaskManagement.EntityFrameworkCore;
using LINGYUN.Abp.TextTemplating;
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore;
using LINGYUN.Abp.WebhooksManagement;
using LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore;
using LINGYUN.Platform.Datas;
using LINGYUN.Platform.EntityFrameworkCore;
using LINGYUN.Platform.Layouts;
using LINGYUN.Platform.Menus;
using LINGYUN.Platform.Messages;
using LINGYUN.Platform.Packages;
using LINGYUN.Platform.Portal;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.AuditLogging;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.FeatureManagement;
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.OpenIddict.Applications;
using Volo.Abp.OpenIddict.Authorizations;
using Volo.Abp.OpenIddict.EntityFrameworkCore;
using Volo.Abp.OpenIddict.Scopes;
using Volo.Abp.OpenIddict.Tokens;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
namespace LY.MicroService.Applications.Single.EntityFrameworkCore;
[ConnectionStringName("SingleDbMigrator")]
public class SingleMigrationsDbContext : AbpDbContext<SingleMigrationsDbContext>
[ReplaceDbContext(typeof(IAuditLoggingDbContext))]
[ReplaceDbContext(typeof(IIdentityDbContext))]
[ReplaceDbContext(typeof(IOpenIddictDbContext))]
[ReplaceDbContext(typeof(ISaasDbContext))]
[ReplaceDbContext(typeof(IFeatureManagementDbContext))]
[ReplaceDbContext(typeof(ISettingManagementDbContext))]
[ReplaceDbContext(typeof(IPermissionManagementDbContext))]
[ReplaceDbContext(typeof(ITextTemplatingDbContext))]
[ReplaceDbContext(typeof(ITaskManagementDbContext))]
[ReplaceDbContext(typeof(IWebhooksManagementDbContext))]
[ReplaceDbContext(typeof(IPlatformDbContext))]
[ReplaceDbContext(typeof(ILocalizationDbContext))]
[ReplaceDbContext(typeof(INotificationsDbContext))]
[ReplaceDbContext(typeof(INotificationsDefinitionDbContext))]
[ReplaceDbContext(typeof(IMessageServiceDbContext))]
[ReplaceDbContext(typeof(IAbpDataProtectionManagementDbContext))]
[ReplaceDbContext(typeof(IGdprDbContext))]
[ReplaceDbContext(typeof(IDemoDbContext))]
[ConnectionStringName("Default")]
public class SingleMigrationsDbContext :
AbpDbContext<SingleMigrationsDbContext>,
IAuditLoggingDbContext,
IIdentityDbContext,
IOpenIddictDbContext,
ISaasDbContext,
IFeatureManagementDbContext,
ISettingManagementDbContext,
IPermissionManagementDbContext,
ITextTemplatingDbContext,
ITaskManagementDbContext,
IWebhooksManagementDbContext,
IPlatformDbContext,
ILocalizationDbContext,
INotificationsDbContext,
INotificationsDefinitionDbContext,
IMessageServiceDbContext,
IAbpDataProtectionManagementDbContext,
IGdprDbContext,
IDemoDbContext
{
public SingleMigrationsDbContext(DbContextOptions<SingleMigrationsDbContext> options)
: base(options)
@ -30,6 +97,136 @@ public class SingleMigrationsDbContext : AbpDbContext<SingleMigrationsDbContext>
}
public DbSet<AuditLog> AuditLogs { get; set; }
public DbSet<AuditLogExcelFile> AuditLogExcelFiles { get; set; }
public DbSet<IdentityUser> Users { get; set; }
public DbSet<IdentityRole> Roles { get; set; }
public DbSet<IdentityClaimType> ClaimTypes { get; set; }
public DbSet<OrganizationUnit> OrganizationUnits { get; set; }
public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }
public DbSet<IdentityLinkUser> LinkUsers { get; set; }
public DbSet<IdentityUserDelegation> UserDelegations { get; set; }
public DbSet<IdentitySession> Sessions { get; set; }
public DbSet<OpenIddictApplication> Applications { get; set; }
public DbSet<OpenIddictAuthorization> Authorizations { get; set; }
public DbSet<OpenIddictScope> Scopes { get; set; }
public DbSet<OpenIddictToken> Tokens { get; set; }
public DbSet<Edition> Editions { get; set; }
public DbSet<Tenant> Tenants { get; set; }
public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }
public DbSet<FeatureGroupDefinitionRecord> FeatureGroups { get; set; }
public DbSet<FeatureDefinitionRecord> Features { get; set; }
public DbSet<FeatureValue> FeatureValues { get; set; }
public DbSet<Setting> Settings { get; set; }
public DbSet<SettingDefinitionRecord> SettingDefinitionRecords { get; set; }
public DbSet<PermissionGroupDefinitionRecord> PermissionGroups { get; set; }
public DbSet<PermissionDefinitionRecord> Permissions { get; set; }
public DbSet<PermissionGrant> PermissionGrants { get; set; }
public DbSet<TextTemplate> TextTemplates { get; set; }
public DbSet<TextTemplateDefinition> TextTemplateDefinitions { get; set; }
public DbSet<BackgroundJobInfo> BackgroundJobInfos { get; set; }
public DbSet<BackgroundJobAction> BackgroundJobAction { get; set; }
public DbSet<WebhookSendRecord> WebhookSendRecord { get; set; }
public DbSet<WebhookGroupDefinitionRecord> WebhookGroupDefinitionRecords { get; set; }
public DbSet<WebhookDefinitionRecord> WebhookDefinitionRecords { get; set; }
public DbSet<Menu> Menus { get; set; }
public DbSet<Layout> Layouts { get; set; }
public DbSet<RoleMenu> RoleMenus { get; set; }
public DbSet<UserMenu> UserMenus { get; set; }
public DbSet<UserFavoriteMenu> UserFavoriteMenus { get; set; }
public DbSet<Data> Datas { get; set; }
public DbSet<DataItem> DataItems { get; set; }
public DbSet<Package> Packages { get; set; }
public DbSet<PackageBlob> PackageBlobs { get; set; }
public DbSet<Enterprise> Enterprises { get; set; }
public DbSet<EmailMessage> EmailMessages { get; set; }
public DbSet<SmsMessage> SmsMessages { get; set; }
public DbSet<Resource> Resources { get; set; }
public DbSet<Language> Languages { get; set; }
public DbSet<Text> Texts { get; set; }
public DbSet<Notification> Notifications { get; set; }
public DbSet<UserNotification> UserNotifications { get; set; }
public DbSet<UserSubscribe> UserSubscribes { get; set; }
public DbSet<NotificationDefinitionGroupRecord> NotificationDefinitionGroupRecords { get; set; }
public DbSet<NotificationDefinitionRecord> NotificationDefinitionRecords { get; set; }
public DbSet<UserMessage> UserMessages { get; set; }
public DbSet<GroupMessage> GroupMessages { get; set; }
public DbSet<UserChatFriend> UserChatFriends { get; set; }
public DbSet<UserChatSetting> UserChatSettings { get; set; }
public DbSet<GroupChatBlack> GroupChatBlacks { get; set; }
public DbSet<ChatGroup> ChatGroups { get; set; }
public DbSet<UserChatGroup> UserChatGroups { get; set; }
public DbSet<UserChatCard> UserChatCards { get; set; }
public DbSet<UserGroupCard> UserGroupCards { get; set; }
public DbSet<EntityTypeInfo> EntityTypeInfos { get; set; }
public DbSet<GdprRequest> Requests { get; set; }
public DbSet<Book> Books { get; set; }
public DbSet<Author> Authors { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
@ -50,7 +247,6 @@ public class SingleMigrationsDbContext : AbpDbContext<SingleMigrationsDbContext>
modelBuilder.ConfigureNotificationsDefinition();
modelBuilder.ConfigureMessageService();
modelBuilder.ConfigureDataProtectionManagement();
modelBuilder.ConfigureWebhooksManagement();
modelBuilder.ConfigureGdpr();
modelBuilder.ConfigureDemo();

6
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleMigrationsEntityFrameworkCoreModule.cs

@ -12,6 +12,7 @@ using LINGYUN.Abp.WebhooksManagement.EntityFrameworkCore;
using LINGYUN.Abp.WeChat;
using LINGYUN.Platform.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Data;
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.Modularity;
using Volo.Abp.OpenIddict.EntityFrameworkCore;
@ -43,6 +44,9 @@ public class SingleMigrationsEntityFrameworkCoreModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<SingleMigrationsDbContext>();
if (context.Services.IsDataMigrationEnvironment())
{
context.Services.AddAbpDbContext<SingleMigrationsDbContext>();
}
}
}

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

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

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

@ -22,6 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\..\framework\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" />
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.Quartz.MySqlInstaller\LINGYUN.Abp.Quartz.MySqlInstaller.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.TaskManagement.EntityFrameworkCore\LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj" />
</ItemGroup>

2
aspnet-core/migrations/LY.MicroService.TaskManagement.EntityFrameworkCore/TaskManagementMigrationsEntityFrameworkCoreModule.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.Data.DbMigrator;
using LINGYUN.Abp.Quartz.MySqlInstaller;
using LINGYUN.Abp.Saas.EntityFrameworkCore;
using LINGYUN.Abp.TaskManagement.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
@ -13,6 +14,7 @@ using Volo.Abp.SettingManagement.EntityFrameworkCore;
namespace LY.MicroService.TaskManagement.EntityFrameworkCore;
[DependsOn(
typeof(AbpQuartzMySqlInstallerModule),
typeof(AbpSaasEntityFrameworkCoreModule),
typeof(TaskManagementEntityFrameworkCoreModule),
typeof(AbpEntityFrameworkCoreMySQLPomeloModule),

2
aspnet-core/migrations/Migrate.ps1

@ -21,7 +21,7 @@ $dbContexts = @{
Context = "SingleMigrationsDbContext"
Factory = "SingleMigrationsDbContextFactory"
}
3 = @{
"3" = @{
Name = "LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer"
Context = "SingleMigrationsDbContext"
Factory = "SingleMigrationsDbContextFactory"

5
aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/EntityFrameworkCore/DemoDbContext.cs

@ -2,9 +2,12 @@
using LINGYUN.Abp.Demo.Authors;
using LINGYUN.Abp.Demo.Books;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
namespace LINGYUN.Abp.Demo.EntityFrameworkCore;
public class DemoDbContext : AbpDataProtectionDbContext<DemoDbContext>
[ConnectionStringName(DemoDbProterties.ConnectionStringName)]
public class DemoDbContext : AbpDataProtectionDbContext<DemoDbContext>, IDemoDbContext
{
public DbSet<Book> Books { get; set; }

15
aspnet-core/modules/demo/LINGYUN.Abp.Demo.EntityFrameworkCore/LINGYUN/Abp/Demo/EntityFrameworkCore/IDemoDbContext.cs

@ -0,0 +1,15 @@
using LINGYUN.Abp.Demo.Authors;
using LINGYUN.Abp.Demo.Books;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
namespace LINGYUN.Abp.Demo.EntityFrameworkCore;
[ConnectionStringName(DemoDbProterties.ConnectionStringName)]
public interface IDemoDbContext : IEfCoreDbContext
{
DbSet<Book> Books { get; }
DbSet<Author> Authors { get; }
}

15
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN/Abp/Elsa/EntityFrameworkCore/MySql/AbpElsaEntityFrameworkCoreMySqlModule.cs

@ -1,6 +1,10 @@
using Elsa;
using Elsa.Options;
using LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.Migrations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.MySQL;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
@ -35,4 +39,15 @@ public class AbpElsaEntityFrameworkCoreMySqlModule : AbpModule
options.FileSets.AddEmbedded<AbpElsaEntityFrameworkCoreMySqlModule>();
});
}
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (configuration.GetValue<bool>("Elsa:Features:DefaultPersistence:EntityFrameworkCore:MySql:Enabled"))
{
await context.ServiceProvider
.GetService<MySqlElsaDataBaseInstaller>()
?.InstallAsync();
}
}
}

36
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN/Abp/Elsa/EntityFrameworkCore/MySql/Migrations/Initial.sql

@ -313,3 +313,39 @@ INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('20210730112043_Initial', '5.0.10');
COMMIT;
-- secrets
CREATE TABLE IF NOT EXISTS `__EFMigrationsHistory` (
`MigrationId` varchar(150) CHARACTER SET utf8mb4 NOT NULL,
`ProductVersion` varchar(32) CHARACTER SET utf8mb4 NOT NULL,
CONSTRAINT `PK___EFMigrationsHistory` PRIMARY KEY (`MigrationId`)
) CHARACTER SET utf8mb4;
START TRANSACTION;
ALTER DATABASE CHARACTER SET utf8mb4;
CREATE TABLE `Secrets` (
`Id` varchar(255) CHARACTER SET utf8mb4 NOT NULL,
`Type` varchar(255) CHARACTER SET utf8mb4 NULL,
`Name` varchar(255) CHARACTER SET utf8mb4 NULL,
`DisplayName` varchar(255) CHARACTER SET utf8mb4 NULL,
`Data` longtext CHARACTER SET utf8mb4 NULL,
CONSTRAINT `PK_Secrets` PRIMARY KEY (`Id`)
) CHARACTER SET utf8mb4;
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('20220327173004_Initial', '5.0.10');
COMMIT;
START TRANSACTION;
ALTER TABLE `Secrets` MODIFY COLUMN `Name` varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT '';
INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`)
VALUES ('20221209041917_RequireName', '5.0.10');
COMMIT;

1
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql/LINGYUN/Abp/Elsa/EntityFrameworkCore/MySql/Migrations/MySqlElsaDataBaseInstaller.cs

@ -15,7 +15,6 @@ using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.Migrations;
[Dependency(ReplaceServices = true)]
public class MySqlElsaDataBaseInstaller : IElsaDataBaseInstaller, ITransientDependency
{
public ILogger<MySqlElsaDataBaseInstaller> Logger { protected get; set; }

5
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql.csproj

@ -13,6 +13,11 @@
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<None Remove="LINGYUN\Abp\Elsa\EntityFrameworkCore\PostgreSql\Migrations\Initial.sql" />
<EmbeddedResource Include="LINGYUN\Abp\Elsa\EntityFrameworkCore\PostgreSql\Migrations\Initial.sql" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Elsa.Webhooks.Persistence.EntityFramework.PostgreSql" />
<PackageReference Include="Elsa.WorkflowSettings.Persistence.EntityFramework.PostgreSql" />

24
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN/Abp/Elsa/EntityFrameworkCore/PostgreSql/AbpElsaEntityFrameworkCorePostgreSqlModule.cs

@ -1,8 +1,13 @@
using Elsa;
using Elsa.Options;
using LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql.Migrations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.PostgreSql;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql;
@ -26,4 +31,23 @@ public class AbpElsaEntityFrameworkCorePostgreSqlModule : AbpModule
elsa.AddFeatures(startups, configuration);
});
}
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpElsaEntityFrameworkCorePostgreSqlModule>();
});
}
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (configuration.GetValue<bool>("Elsa:Features:DefaultPersistence:EntityFrameworkCore:PostgreSql:Enabled"))
{
await context.ServiceProvider
.GetService<PostgreSqlElsaDataBaseInstaller>()
?.InstallAsync();
}
}
}

291
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN/Abp/Elsa/EntityFrameworkCore/PostgreSql/Migrations/Initial.sql

@ -0,0 +1,291 @@
-- basic script
CREATE SCHEMA IF NOT EXISTS "Elsa";
SET search_path TO "Elsa";
CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
"MigrationId" varchar(150) NOT NULL,
"ProductVersion" varchar(32) NOT NULL,
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);
START TRANSACTION;
CREATE TABLE "Bookmarks" (
"Id" varchar(255) NOT NULL,
"TenantId" varchar(255) NULL,
"Hash" varchar(255) NOT NULL,
"Model" text NOT NULL,
"ModelType" text NOT NULL,
"ActivityType" varchar(255) NOT NULL,
"ActivityId" varchar(255) NOT NULL,
"WorkflowInstanceId" varchar(255) NOT NULL,
"CorrelationId" varchar(255) NULL,
CONSTRAINT "PK_Bookmarks" PRIMARY KEY ("Id")
);
CREATE TABLE "WorkflowDefinitions" (
"Id" varchar(255) NOT NULL,
"DefinitionId" varchar(255) NOT NULL,
"TenantId" varchar(255) NULL,
"Name" varchar(255) NULL,
"DisplayName" text NULL,
"Description" text NULL,
"Version" integer NOT NULL,
"IsSingleton" boolean NOT NULL,
"PersistenceBehavior" integer NOT NULL,
"DeleteCompletedInstances" boolean NOT NULL,
"IsPublished" boolean NOT NULL,
"IsLatest" boolean NOT NULL,
"Tag" varchar(255) NULL,
"Data" text NULL,
CONSTRAINT "PK_WorkflowDefinitions" PRIMARY KEY ("Id")
);
CREATE TABLE "WorkflowExecutionLogRecords" (
"Id" varchar(255) NOT NULL,
"TenantId" varchar(255) NULL,
"WorkflowInstanceId" varchar(255) NOT NULL,
"ActivityId" varchar(255) NOT NULL,
"ActivityType" varchar(255) NOT NULL,
"Timestamp" timestamp with time zone NOT NULL,
"EventName" text NULL,
"Message" text NULL,
"Source" text NULL,
"Data" text NULL,
CONSTRAINT "PK_WorkflowExecutionLogRecords" PRIMARY KEY ("Id")
);
CREATE TABLE "WorkflowInstances" (
"Id" varchar(255) NOT NULL,
"DefinitionId" varchar(255) NOT NULL,
"TenantId" varchar(255) NULL,
"Version" integer NOT NULL,
"WorkflowStatus" integer NOT NULL,
"CorrelationId" varchar(255) NULL,
"ContextType" varchar(255) NULL,
"ContextId" varchar(255) NULL,
"Name" varchar(255) NULL,
"CreatedAt" timestamp with time zone NOT NULL,
"LastExecutedAt" timestamp with time zone NULL,
"FinishedAt" timestamp with time zone NULL,
"CancelledAt" timestamp with time zone NULL,
"FaultedAt" timestamp with time zone NULL,
"Data" text NULL,
CONSTRAINT "PK_WorkflowInstances" PRIMARY KEY ("Id")
);
CREATE INDEX "IX_Bookmark_ActivityId" ON "Bookmarks" ("ActivityId");
CREATE INDEX "IX_Bookmark_ActivityType" ON "Bookmarks" ("ActivityType");
CREATE INDEX "IX_Bookmark_ActivityType_TenantId_Hash" ON "Bookmarks" ("ActivityType", "TenantId", "Hash");
CREATE INDEX "IX_Bookmark_CorrelationId" ON "Bookmarks" ("CorrelationId");
CREATE INDEX "IX_Bookmark_Hash" ON "Bookmarks" ("Hash");
CREATE INDEX "IX_Bookmark_Hash_CorrelationId_TenantId" ON "Bookmarks" ("Hash", "CorrelationId", "TenantId");
CREATE INDEX "IX_Bookmark_TenantId" ON "Bookmarks" ("TenantId");
CREATE INDEX "IX_Bookmark_WorkflowInstanceId" ON "Bookmarks" ("WorkflowInstanceId");
CREATE UNIQUE INDEX "IX_WorkflowDefinition_DefinitionId_VersionId" ON "WorkflowDefinitions" ("DefinitionId", "Version");
CREATE INDEX "IX_WorkflowDefinition_IsLatest" ON "WorkflowDefinitions" ("IsLatest");
CREATE INDEX "IX_WorkflowDefinition_IsPublished" ON "WorkflowDefinitions" ("IsPublished");
CREATE INDEX "IX_WorkflowDefinition_Name" ON "WorkflowDefinitions" ("Name");
CREATE INDEX "IX_WorkflowDefinition_Tag" ON "WorkflowDefinitions" ("Tag");
CREATE INDEX "IX_WorkflowDefinition_TenantId" ON "WorkflowDefinitions" ("TenantId");
CREATE INDEX "IX_WorkflowDefinition_Version" ON "WorkflowDefinitions" ("Version");
CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityId" ON "WorkflowExecutionLogRecords" ("ActivityId");
CREATE INDEX "IX_WorkflowExecutionLogRecord_ActivityType" ON "WorkflowExecutionLogRecords" ("ActivityType");
CREATE INDEX "IX_WorkflowExecutionLogRecord_TenantId" ON "WorkflowExecutionLogRecords" ("TenantId");
CREATE INDEX "IX_WorkflowExecutionLogRecord_Timestamp" ON "WorkflowExecutionLogRecords" ("Timestamp");
CREATE INDEX "IX_WorkflowExecutionLogRecord_WorkflowInstanceId" ON "WorkflowExecutionLogRecords" ("WorkflowInstanceId");
CREATE INDEX "IX_WorkflowInstance_ContextId" ON "WorkflowInstances" ("ContextId");
CREATE INDEX "IX_WorkflowInstance_ContextType" ON "WorkflowInstances" ("ContextType");
CREATE INDEX "IX_WorkflowInstance_CorrelationId" ON "WorkflowInstances" ("CorrelationId");
CREATE INDEX "IX_WorkflowInstance_CreatedAt" ON "WorkflowInstances" ("CreatedAt");
CREATE INDEX "IX_WorkflowInstance_DefinitionId" ON "WorkflowInstances" ("DefinitionId");
CREATE INDEX "IX_WorkflowInstance_FaultedAt" ON "WorkflowInstances" ("FaultedAt");
CREATE INDEX "IX_WorkflowInstance_FinishedAt" ON "WorkflowInstances" ("FinishedAt");
CREATE INDEX "IX_WorkflowInstance_LastExecutedAt" ON "WorkflowInstances" ("LastExecutedAt");
CREATE INDEX "IX_WorkflowInstance_Name" ON "WorkflowInstances" ("Name");
CREATE INDEX "IX_WorkflowInstance_TenantId" ON "WorkflowInstances" ("TenantId");
CREATE INDEX "IX_WorkflowInstance_WorkflowStatus" ON "WorkflowInstances" ("WorkflowStatus");
CREATE INDEX "IX_WorkflowInstance_WorkflowStatus_DefinitionId" ON "WorkflowInstances" ("WorkflowStatus", "DefinitionId");
CREATE INDEX "IX_WorkflowInstance_WorkflowStatus_DefinitionId_Version" ON "WorkflowInstances" ("WorkflowStatus", "DefinitionId", "Version");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210523093427_Initial', '5.0.10');
COMMIT;
START TRANSACTION;
ALTER TABLE "WorkflowInstances"
ALTER COLUMN "CorrelationId" SET DEFAULT '',
ALTER COLUMN "CorrelationId" SET NOT NULL;
ALTER TABLE "WorkflowInstances" ADD "LastExecutedActivityId" text NULL;
ALTER TABLE "WorkflowDefinitions" ADD "OutputStorageProviderName" text NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210611200027_Update21', '5.0.10');
COMMIT;
START TRANSACTION;
ALTER TABLE "WorkflowDefinitions" DROP COLUMN "OutputStorageProviderName";
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210923112211_Update23', '5.0.10');
COMMIT;
START TRANSACTION;
ALTER TABLE "WorkflowInstances" ADD "DefinitionVersionId" text NOT NULL;
ALTER TABLE "Bookmarks"
ALTER COLUMN "CorrelationId" SET DEFAULT '',
ALTER COLUMN "CorrelationId" SET NOT NULL;
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20211215100204_Update24', '5.0.10');
COMMIT;
START TRANSACTION;
ALTER TABLE "WorkflowInstances"
ALTER COLUMN "DefinitionVersionId" TYPE varchar(255);
CREATE INDEX "IX_WorkflowInstance_DefinitionVersionId" ON "WorkflowInstances" ("DefinitionVersionId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220120170050_Update241', '5.0.10');
COMMIT;
START TRANSACTION;
CREATE TABLE "Triggers" (
"Id" varchar(255) NOT NULL,
"TenantId" varchar(255) NULL,
"Hash" varchar(255) NOT NULL,
"Model" text NOT NULL,
"ModelType" text NOT NULL,
"ActivityType" varchar(255) NOT NULL,
"ActivityId" varchar(255) NOT NULL,
"WorkflowDefinitionId" varchar(255) NOT NULL,
CONSTRAINT "PK_Triggers" PRIMARY KEY ("Id")
);
CREATE INDEX "IX_Trigger_ActivityId" ON "Triggers" ("ActivityId");
CREATE INDEX "IX_Trigger_ActivityType" ON "Triggers" ("ActivityType");
CREATE INDEX "IX_Trigger_ActivityType_TenantId_Hash" ON "Triggers" ("ActivityType", "TenantId", "Hash");
CREATE INDEX "IX_Trigger_Hash" ON "Triggers" ("Hash");
CREATE INDEX "IX_Trigger_Hash_TenantId" ON "Triggers" ("Hash", "TenantId");
CREATE INDEX "IX_Trigger_TenantId" ON "Triggers" ("TenantId");
CREATE INDEX "IX_Trigger_WorkflowDefinitionId" ON "Triggers" ("WorkflowDefinitionId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220120204150_Update25', '5.0.10');
COMMIT;
START TRANSACTION;
ALTER TABLE "WorkflowDefinitions" ADD "CreatedAt" timestamp with time zone NOT NULL DEFAULT '0001-01-01 00:00:00';
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20220512203646_Update28', '5.0.10');
COMMIT;
-- webhooks
CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
"MigrationId" varchar(150) NOT NULL,
"ProductVersion" varchar(32) NOT NULL,
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);
START TRANSACTION;
CREATE TABLE "WebhookDefinitions" (
"Id" varchar(255) NOT NULL,
"TenantId" varchar(255) NULL,
"Name" varchar(255) NOT NULL,
"Path" varchar(255) NOT NULL,
"Description" varchar(255) NULL,
"PayloadTypeName" varchar(255) NULL,
"IsEnabled" boolean NOT NULL,
CONSTRAINT "PK_WebhookDefinitions" PRIMARY KEY ("Id")
);
CREATE INDEX "IX_WebhookDefinition_Description" ON "WebhookDefinitions" ("Description");
CREATE INDEX "IX_WebhookDefinition_IsEnabled" ON "WebhookDefinitions" ("IsEnabled");
CREATE INDEX "IX_WebhookDefinition_Name" ON "WebhookDefinitions" ("Name");
CREATE INDEX "IX_WebhookDefinition_Path" ON "WebhookDefinitions" ("Path");
CREATE INDEX "IX_WebhookDefinition_PayloadTypeName" ON "WebhookDefinitions" ("PayloadTypeName");
CREATE INDEX "IX_WebhookDefinition_TenantId" ON "WebhookDefinitions" ("TenantId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210604065041_Initial', '5.0.10');
COMMIT;
-- workflow-settings
CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
"MigrationId" varchar(150) NOT NULL,
"ProductVersion" varchar(32) NOT NULL,
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);
START TRANSACTION;
CREATE TABLE "WorkflowSettings" (
"Id" varchar(255) NOT NULL,
"WorkflowBlueprintId" varchar(255) NULL,
"Key" varchar(255) NULL,
"Value" varchar(255) NULL,
CONSTRAINT "PK_WorkflowSettings" PRIMARY KEY ("Id")
);
CREATE INDEX "IX_WorkflowSetting_Key" ON "WorkflowSettings" ("Key");
CREATE INDEX "IX_WorkflowSetting_Value" ON "WorkflowSettings" ("Value");
CREATE INDEX "IX_WorkflowSetting_WorkflowBlueprintId" ON "WorkflowSettings" ("WorkflowBlueprintId");
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20210730112043_Initial', '5.0.10');
COMMIT;
-- secrets
CREATE TABLE IF NOT EXISTS "__EFMigrationsHistory" (
"MigrationId" varchar(150) NOT NULL,
"ProductVersion" varchar(32) NOT NULL,
CONSTRAINT "PK___EFMigrationsHistory" PRIMARY KEY ("MigrationId")
);
START TRANSACTION;
CREATE TABLE "Secrets" (
"Id" varchar(255) NOT NULL,
"Type" text NOT NULL,
"Name" text NOT NULL,
"DisplayName" text NULL,
"Data" text NULL,
CONSTRAINT "PK_Secrets" PRIMARY KEY ("Id")
);
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20230709045349_Initial', '5.0.10');
COMMIT;

143
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql/LINGYUN/Abp/Elsa/EntityFrameworkCore/PostgreSql/Migrations/PostgreSqlElsaDataBaseInstaller.cs

@ -0,0 +1,143 @@
using LINGYUN.Abp.Elsa.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Npgsql;
using NpgsqlTypes;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql.Migrations;
public class PostgreSqlElsaDataBaseInstaller : IElsaDataBaseInstaller, ITransientDependency
{
public ILogger<PostgreSqlElsaDataBaseInstaller> Logger { protected get; set; }
private readonly IVirtualFileProvider _virtualFileProvider;
private readonly IConnectionStringResolver _connectionStringResolver;
private readonly AbpElsaDataBaseInstallerOptions _installerOptions;
public PostgreSqlElsaDataBaseInstaller(
IVirtualFileProvider virtualFileProvider,
IConnectionStringResolver connectionStringResolver,
IOptions<AbpElsaDataBaseInstallerOptions> installerOptions)
{
_installerOptions = installerOptions.Value;
_virtualFileProvider = virtualFileProvider;
_connectionStringResolver = connectionStringResolver;
Logger = NullLogger<PostgreSqlElsaDataBaseInstaller>.Instance;
}
public async virtual Task InstallAsync()
{
var connectionString = await _connectionStringResolver.ResolveAsync("Workflow");
if (connectionString.IsNullOrWhiteSpace())
{
Logger.LogWarning("Please configure the `Workflow` database connection string Workflow!");
throw new ArgumentNullException(nameof(connectionString));
}
var builder = new NpgsqlConnectionStringBuilder(connectionString);
var dataBaseName = await CreateDataBaseIfNotExists(builder.Database, builder);
builder.Database = dataBaseName;
using var npgsqlConnection = new NpgsqlConnection(builder.ConnectionString);
if (npgsqlConnection.State == ConnectionState.Closed)
{
await npgsqlConnection.OpenAsync();
}
var tableParams = _installerOptions.InstallTables.Select((_, index) => $"@Table_{index}").JoinAsString(",");
// ElsaContext中默认使用Elsa作为默认Schema
using (var npgsqlCommand = new NpgsqlCommand($"SELECT COUNT(1) FROM information_schema.tables WHERE table_catalog = @DataBaseName AND table_schema = 'Elsa' AND table_name IN ({tableParams});", npgsqlConnection))
{
npgsqlCommand.Parameters.Add("@DataBaseName", NpgsqlDbType.Text).Value = dataBaseName;
for (var index = 0; index < _installerOptions.InstallTables.Count; index++)
{
npgsqlCommand.Parameters.Add($"@Table_{index}", NpgsqlDbType.Text).Value = _installerOptions.InstallTables[index];
}
var rowsAffects = await npgsqlCommand.ExecuteScalarAsync() as long?;
if (rowsAffects > 0)
{
Logger.LogInformation($"The `{dataBaseName}` database has already exists.");
return;
}
}
var sqlScript = await GetInitSqlScript();
// ${DataBase} 替换
sqlScript = sqlScript.ReplaceFirst("${DataBase}", dataBaseName);
using (var npgsqlCommand = new NpgsqlCommand(sqlScript, npgsqlConnection))
{
Logger.LogInformation("The database initialization script `Initial.sql` starts...");
await npgsqlCommand.ExecuteNonQueryAsync();
}
Logger.LogInformation("Database initialization script `Initial.sql` complete!");
}
public async virtual Task<string> CreateDataBaseIfNotExists(string dataBase, NpgsqlConnectionStringBuilder connectionStringBuilder)
{
// 切换主数据库查询数据库是否存在
connectionStringBuilder.Database = "postgres";
using var npgsqlConnection = new NpgsqlConnection(connectionStringBuilder.ConnectionString);
if (npgsqlConnection.State == ConnectionState.Closed)
{
await npgsqlConnection.OpenAsync();
}
var checkDataBaseName = "";
using (var npgsqlCommand = new NpgsqlCommand("SELECT datname FROM pg_database WHERE datname = @DataBaseName;", npgsqlConnection))
{
var dataBaseParamter = npgsqlCommand.Parameters.Add("DataBaseName", NpgsqlDbType.Text);
dataBaseParamter.Value = dataBase;
checkDataBaseName = await npgsqlCommand.ExecuteScalarAsync() as string;
}
if (checkDataBaseName.IsNullOrWhiteSpace())
{
using (var npgsqlCommand = new NpgsqlCommand($"CREATE DATABASE \"{dataBase}\" ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8';", npgsqlConnection))
{
await npgsqlCommand.ExecuteNonQueryAsync();
}
}
return dataBase;
}
public async virtual Task<string> GetInitSqlScript()
{
var sqlScriptFileInfo = _virtualFileProvider.GetFileInfo("/LINGYUN/Abp/Elsa/EntityFrameworkCore/PostgreSql/Migrations/Initial.sql");
if (!sqlScriptFileInfo.Exists || sqlScriptFileInfo.IsDirectory)
{
Logger.LogWarning("Please Check that the `Initial.sql` file exists!");
throw new InvalidOperationException("The `Initial.sql` database initialization script file does not exist or is not valid!");
}
var sqlScript = await sqlScriptFileInfo.ReadAsStringAsync();
if (sqlScript.IsNullOrWhiteSpace())
{
Logger.LogWarning("The contents of the `Initial.sql` file are empty or invalid!");
throw new InvalidOperationException("The contents of the `Initial.sql` file are empty or invalid!");
}
return sqlScript;
}
}

15
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer/LINGYUN/Abp/Elsa/EntityFrameworkCore/SqlServer/AbpElsaEntityFrameworkCoreSqlServerModule.cs

@ -1,6 +1,10 @@
using Elsa;
using Elsa.Options;
using LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer.Migrations;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.SqlServer;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
@ -35,4 +39,15 @@ public class AbpElsaEntityFrameworkCoreSqlServerModule : AbpModule
options.FileSets.AddEmbedded<AbpElsaEntityFrameworkCoreSqlServerModule>();
});
}
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (configuration.GetValue<bool>("Elsa:Features:DefaultPersistence:EntityFrameworkCore:SqlServer:Enabled"))
{
await context.ServiceProvider
.GetService<SqlServerElsaDataBaseInstaller>()
?.InstallAsync();
}
}
}

315
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer/LINGYUN/Abp/Elsa/EntityFrameworkCore/SqlServer/Migrations/Initial.sql

@ -1,11 +1,18 @@
USE [${DataBase}];
-- Elsa Schema
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'Elsa')
BEGIN
EXEC('CREATE SCHEMA Elsa');
END;
-- ----------------------------
-- Table structure for __EFMigrationsHistory
-- ----------------------------
IF OBJECT_ID(N'[__EFMigrationsHistory]') IS NULL
IF OBJECT_ID(N'[Elsa].[__EFMigrationsHistory]') IS NULL
BEGIN
CREATE TABLE [__EFMigrationsHistory] (
CREATE TABLE [Elsa].[__EFMigrationsHistory] (
[MigrationId] nvarchar(150) NOT NULL,
[ProductVersion] nvarchar(32) NOT NULL,
CONSTRAINT [PK___EFMigrationsHistory] PRIMARY KEY ([MigrationId])
@ -16,32 +23,16 @@ END;
-- Table structure for bookmarks
-- ----------------------------
CREATE TABLE [dbo].[Bookmarks] (
[Id] nvarchar(255) NOT NULL,
[TenantId] nvarchar(255) NULL,
[Hash] nvarchar(255) NOT NULL,
[Model] nvarchar(max) NOT NULL,
[ModelType] nvarchar(max) NOT NULL,
[ActivityType] nvarchar(255) NOT NULL,
[ActivityId] nvarchar(255) NOT NULL,
[WorkflowInstanceId] nvarchar(255) NOT NULL,
[CorrelationId] nvarchar(255) NOT NULL
)
-- ----------------------------
-- Table structure for triggers
-- ----------------------------
CREATE TABLE [dbo].[Triggers] (
[Id] nvarchar(255) NOT NULL,
[TenantId] nvarchar(255) NULL,
[Hash] nvarchar(255) NOT NULL,
CREATE TABLE [Elsa].[Bookmarks] (
[Id] nvarchar(450) NOT NULL,
[TenantId] nvarchar(450) NULL,
[Hash] nvarchar(450) NOT NULL,
[Model] nvarchar(max) NOT NULL,
[ModelType] nvarchar(max) NOT NULL,
[ActivityType] nvarchar(255) NOT NULL,
[ActivityId] nvarchar(255) NOT NULL,
[WorkflowDefinitionId] nvarchar(255) NOT NULL
[ActivityType] nvarchar(450) NOT NULL,
[ActivityId] nvarchar(450) NOT NULL,
[WorkflowInstanceId] nvarchar(450) NOT NULL,
[CorrelationId] nvarchar(450) NOT NULL
)
@ -49,22 +40,23 @@ CREATE TABLE [dbo].[Triggers] (
-- Table structure for workflowdefinitions
-- ----------------------------
CREATE TABLE [dbo].[WorkflowDefinitions] (
[Id] nvarchar(255) NOT NULL,
[DefinitionId] nvarchar(255) NOT NULL,
[TenantId] nvarchar(255) NULL,
[Name] nvarchar(255) NULL,
CREATE TABLE [Elsa].[WorkflowDefinitions] (
[Id] nvarchar(450) NOT NULL,
[DefinitionId] nvarchar(450) NOT NULL,
[TenantId] nvarchar(450) NULL,
[Name] nvarchar(450) NULL,
[DisplayName] nvarchar(max) NULL,
[Description] nvarchar(max) NULL,
[Version] int NOT NULL,
[IsSingleton] tinyint NOT NULL,
[IsSingleton] bit NOT NULL,
[PersistenceBehavior] int NOT NULL,
[DeleteCompletedInstances] tinyint NOT NULL,
[IsPublished] tinyint NOT NULL,
[IsLatest] tinyint NOT NULL,
[Tag] nvarchar(255) NULL,
[DeleteCompletedInstances] bit NOT NULL,
[IsPublished] bit NOT NULL,
[IsLatest] bit NOT NULL,
[Tag] nvarchar(450) NULL,
[Data] nvarchar(max) NULL,
[CreatedAt] datetime2 NOT NULL
[OutputStorageProviderName] nvarchar(max) NULL,
[CreatedAt] datetimeoffset NOT NULL
)
@ -72,13 +64,13 @@ CREATE TABLE [dbo].[WorkflowDefinitions] (
-- Table structure for workflowexecutionlogrecords
-- ----------------------------
CREATE TABLE [dbo].[WorkflowExecutionLogRecords] (
[Id] nvarchar(255) NOT NULL,
[TenantId] nvarchar(255) NULL,
[WorkflowInstanceId] nvarchar(255) NOT NULL,
[ActivityId] nvarchar(255) NOT NULL,
[ActivityType] nvarchar(255) NOT NULL,
[Timestamp] datetime2 NOT NULL,
CREATE TABLE [Elsa].[WorkflowExecutionLogRecords] (
[Id] nvarchar(450) NOT NULL,
[TenantId] nvarchar(450) NULL,
[WorkflowInstanceId] nvarchar(450) NOT NULL,
[ActivityId] nvarchar(450) NOT NULL,
[ActivityType] nvarchar(450) NOT NULL,
[Timestamp] datetimeoffset NOT NULL,
[EventName] nvarchar(max) NULL,
[Message] nvarchar(max) NULL,
[Source] nvarchar(max) NULL,
@ -90,24 +82,40 @@ CREATE TABLE [dbo].[WorkflowExecutionLogRecords] (
-- Table structure for workflowinstances
-- ----------------------------
CREATE TABLE [dbo].[WorkflowInstances] (
[Id] nvarchar(255) NOT NULL,
[DefinitionId] nvarchar(255) NOT NULL,
[TenantId] nvarchar(255) NULL,
CREATE TABLE [Elsa].[WorkflowInstances] (
[Id] nvarchar(450) NOT NULL,
[DefinitionId] nvarchar(450) NOT NULL,
[TenantId] nvarchar(450) NULL,
[Version] int NOT NULL,
[WorkflowStatus] int NOT NULL,
[CorrelationId] nvarchar(255) NOT NULL,
[ContextType] nvarchar(255) NULL,
[ContextId] nvarchar(255) NULL,
[Name] nvarchar(255) NULL,
[CreatedAt] datetime2 NOT NULL,
[LastExecutedAt] datetime2 NULL,
[FinishedAt] datetime2 NULL,
[CancelledAt] datetime2 NULL,
[FaultedAt] datetime2 NULL,
[CorrelationId] nvarchar(450) NOT NULL,
[ContextType] nvarchar(450) NULL,
[ContextId] nvarchar(450) NULL,
[Name] nvarchar(450) NULL,
[CreatedAt] datetimeoffset NOT NULL,
[LastExecutedAt] datetimeoffset NULL,
[FinishedAt] datetimeoffset NULL,
[CancelledAt] datetimeoffset NULL,
[FaultedAt] datetimeoffset NULL,
[Data] nvarchar(max) NULL,
[LastExecutedActivityId] nvarchar(max) NULL,
[DefinitionVersionId] nvarchar(255) NOT NULL
[DefinitionVersionId] nvarchar(450) NOT NULL
)
-- ----------------------------
-- Table structure for triggers
-- ----------------------------
CREATE TABLE [Elsa].[Triggers] (
[Id] nvarchar(450) NOT NULL,
[TenantId] nvarchar(450) NULL,
[Hash] nvarchar(450) NOT NULL,
[Model] nvarchar(max) NOT NULL,
[ModelType] nvarchar(max) NOT NULL,
[ActivityType] nvarchar(450) NOT NULL,
[ActivityId] nvarchar(450) NOT NULL,
[WorkflowDefinitionId] nvarchar(450) NOT NULL
)
@ -115,11 +123,39 @@ CREATE TABLE [dbo].[WorkflowInstances] (
-- Table structure for workflowsettings
-- ----------------------------
CREATE TABLE [dbo].[WorkflowSettings] (
[Id] nvarchar(255) NOT NULL,
[WorkflowBlueprintId] nvarchar(255) NULL,
[Key] nvarchar(255) NULL,
[Value] nvarchar(255) NULL
CREATE TABLE [Elsa].[WorkflowSettings] (
[Id] nvarchar(450) NOT NULL,
[WorkflowBlueprintId] nvarchar(450) NULL,
[Key] nvarchar(450) NULL,
[Value] nvarchar(450) NULL
)
-- ----------------------------
-- Table structure for secrets
-- ----------------------------
CREATE TABLE [Elsa].[Secrets] (
[Id] nvarchar(450) NOT NULL,
[Type] nvarchar(max) NOT NULL,
[Name] nvarchar(max) NOT NULL,
[DisplayName] nvarchar(max) NULL,
[Data] nvarchar(max) NULL
)
-- ----------------------------
-- Table structure for webhookdefinitions
-- ----------------------------
CREATE TABLE [Elsa].[WebhookDefinitions] (
[Id] nvarchar(450) NOT NULL,
[TenantId] nvarchar(450) NULL,
[Name] nvarchar(450) NOT NULL,
[Path] nvarchar(450) NOT NULL,
[Description] nvarchar(450) NULL,
[PayloadTypeName] nvarchar(450) NULL,
[IsEnabled] bit NOT NULL
)
@ -127,46 +163,46 @@ CREATE TABLE [dbo].[WorkflowSettings] (
-- Indexes structure for table bookmarks
-- ----------------------------
CREATE NONCLUSTERED INDEX [IX_Bookmark_ActivityId]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[ActivityId] ASC
)
CREATE NONCLUSTERED INDEX [IX_Bookmark_ActivityType]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[ActivityType] ASC
)
CREATE NONCLUSTERED INDEX [IX_Bookmark_ActivityType_TenantId_Hash]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[ActivityType] ASC,
[TenantId] ASC,
[Hash] ASC
)
CREATE NONCLUSTERED INDEX [IX_Bookmark_CorrelationId]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[CorrelationId] ASC
)
CREATE NONCLUSTERED INDEX [IX_Bookmark_Hash]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[Hash] ASC
)
CREATE NONCLUSTERED INDEX [IX_Bookmark_Hash_CorrelationId_TenantId]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[Hash] ASC,
[CorrelationId] ASC,
[TenantId] ASC
)
CREATE NONCLUSTERED INDEX [IX_Bookmark_TenantId]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[TenantId] ASC
)
CREATE NONCLUSTERED INDEX [IX_Bookmark_WorkflowInstanceId]
ON [dbo].[Bookmarks] (
ON [Elsa].[Bookmarks] (
[WorkflowInstanceId] ASC
)
@ -174,7 +210,7 @@ ON [dbo].[Bookmarks] (
-- ----------------------------
-- Primary Key structure for table bookmarks
-- ----------------------------
ALTER TABLE [dbo].[Bookmarks] ADD PRIMARY KEY CLUSTERED ([Id])
ALTER TABLE [Elsa].[Bookmarks] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
@ -182,40 +218,40 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW
-- Indexes structure for table triggers
-- ----------------------------
CREATE NONCLUSTERED INDEX [IX_Trigger_ActivityId]
ON [dbo].[Triggers] (
ON [Elsa].[Triggers] (
[ActivityId] ASC
)
CREATE NONCLUSTERED INDEX [IX_Trigger_ActivityType]
ON [dbo].[Triggers] (
ON [Elsa].[Triggers] (
[ActivityType] ASC
)
CREATE NONCLUSTERED INDEX [IX_Trigger_ActivityType_TenantId_Hash]
ON [dbo].[Triggers] (
ON [Elsa].[Triggers] (
[ActivityType] ASC,
[TenantId] ASC,
[Hash] ASC
)
CREATE NONCLUSTERED INDEX [IX_Trigger_Hash]
ON [dbo].[Triggers] (
ON [Elsa].[Triggers] (
[Hash] ASC
)
CREATE NONCLUSTERED INDEX [IX_Trigger_Hash_TenantId]
ON [dbo].[Triggers] (
ON [Elsa].[Triggers] (
[Hash] ASC,
[TenantId] ASC
)
CREATE NONCLUSTERED INDEX [IX_Trigger_TenantId]
ON [dbo].[Triggers] (
ON [Elsa].[Triggers] (
[TenantId] ASC
)
CREATE NONCLUSTERED INDEX [IX_Trigger_WorkflowDefinitionId]
ON [dbo].[Triggers] (
ON [Elsa].[Triggers] (
[WorkflowDefinitionId] ASC
)
@ -223,7 +259,7 @@ ON [dbo].[Triggers] (
-- ----------------------------
-- Primary Key structure for table triggers
-- ----------------------------
ALTER TABLE [dbo].[Triggers] ADD PRIMARY KEY CLUSTERED ([Id])
ALTER TABLE [Elsa].[Triggers] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
@ -231,38 +267,38 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW
-- Indexes structure for table workflowdefinitions
-- ----------------------------
CREATE UNIQUE NONCLUSTERED INDEX [IX_WorkflowDefinition_DefinitionId_VersionId]
ON [dbo].[WorkflowDefinitions] (
ON [Elsa].[WorkflowDefinitions] (
[DefinitionId] ASC,
[Version] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowDefinition_IsLatest]
ON [dbo].[WorkflowDefinitions] (
ON [Elsa].[WorkflowDefinitions] (
[IsLatest] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowDefinition_IsPublished]
ON [dbo].[WorkflowDefinitions] (
ON [Elsa].[WorkflowDefinitions] (
[IsPublished] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowDefinition_Name]
ON [dbo].[WorkflowDefinitions] (
ON [Elsa].[WorkflowDefinitions] (
[Name] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowDefinition_Tag]
ON [dbo].[WorkflowDefinitions] (
ON [Elsa].[WorkflowDefinitions] (
[Tag] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowDefinition_TenantId]
ON [dbo].[WorkflowDefinitions] (
ON [Elsa].[WorkflowDefinitions] (
[TenantId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowDefinition_Version]
ON [dbo].[WorkflowDefinitions] (
ON [Elsa].[WorkflowDefinitions] (
[Version] ASC
)
@ -270,7 +306,7 @@ ON [dbo].[WorkflowDefinitions] (
-- ----------------------------
-- Primary Key structure for table workflowdefinitions
-- ----------------------------
ALTER TABLE [dbo].[WorkflowDefinitions] ADD PRIMARY KEY CLUSTERED ([Id])
ALTER TABLE [Elsa].[WorkflowDefinitions] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
@ -278,27 +314,27 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW
-- Indexes structure for table workflowexecutionlogrecords
-- ----------------------------
CREATE NONCLUSTERED INDEX [IX_WorkflowExecutionLogRecord_ActivityId]
ON [dbo].[WorkflowExecutionLogRecords] (
ON [Elsa].[WorkflowExecutionLogRecords] (
[ActivityId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowExecutionLogRecord_ActivityType]
ON [dbo].[WorkflowExecutionLogRecords] (
ON [Elsa].[WorkflowExecutionLogRecords] (
[ActivityType] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowExecutionLogRecord_TenantId]
ON [dbo].[WorkflowExecutionLogRecords] (
ON [Elsa].[WorkflowExecutionLogRecords] (
[TenantId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowExecutionLogRecord_Timestamp]
ON [dbo].[WorkflowExecutionLogRecords] (
ON [Elsa].[WorkflowExecutionLogRecords] (
[Timestamp] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowExecutionLogRecord_WorkflowInstanceId]
ON [dbo].[WorkflowExecutionLogRecords] (
ON [Elsa].[WorkflowExecutionLogRecords] (
[WorkflowInstanceId] ASC
)
@ -306,7 +342,7 @@ ON [dbo].[WorkflowExecutionLogRecords] (
-- ----------------------------
-- Primary Key structure for table workflowexecutionlogrecords
-- ----------------------------
ALTER TABLE [dbo].[WorkflowExecutionLogRecords] ADD PRIMARY KEY CLUSTERED ([Id])
ALTER TABLE [Elsa].[WorkflowExecutionLogRecords] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
@ -314,75 +350,75 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW
-- Indexes structure for table workflowinstances
-- ----------------------------
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_ContextId]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[ContextId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_ContextType]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[ContextType] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_CorrelationId]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[CorrelationId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_CreatedAt]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[CreatedAt] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_DefinitionId]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[DefinitionId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_FaultedAt]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[FaultedAt] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_FinishedAt]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[FinishedAt] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_LastExecutedAt]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[LastExecutedAt] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_Name]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[Name] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_TenantId]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[TenantId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_WorkflowStatus]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[WorkflowStatus] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_WorkflowStatus_DefinitionId]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[WorkflowStatus] ASC,
[DefinitionId] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_WorkflowStatus_DefinitionId_Version]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[WorkflowStatus] ASC,
[DefinitionId] ASC,
[Version] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowInstance_DefinitionVersionId]
ON [dbo].[WorkflowInstances] (
ON [Elsa].[WorkflowInstances] (
[DefinitionVersionId] ASC
)
@ -390,7 +426,7 @@ ON [dbo].[WorkflowInstances] (
-- ----------------------------
-- Primary Key structure for table workflowinstances
-- ----------------------------
ALTER TABLE [dbo].[WorkflowInstances] ADD PRIMARY KEY CLUSTERED ([Id])
ALTER TABLE [Elsa].[WorkflowInstances] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
@ -398,17 +434,17 @@ WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW
-- Indexes structure for table workflowsettings
-- ----------------------------
CREATE NONCLUSTERED INDEX [IX_WorkflowSetting_Key]
ON [dbo].[WorkflowSettings] (
ON [Elsa].[WorkflowSettings] (
[Key] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowSetting_Value]
ON [dbo].[WorkflowSettings] (
ON [Elsa].[WorkflowSettings] (
[Value] ASC
)
CREATE NONCLUSTERED INDEX [IX_WorkflowSetting_WorkflowBlueprintId]
ON [dbo].[WorkflowSettings] (
ON [Elsa].[WorkflowSettings] (
[WorkflowBlueprintId] ASC
)
@ -416,10 +452,57 @@ ON [dbo].[WorkflowSettings] (
-- ----------------------------
-- Primary Key structure for table workflowsettings
-- ----------------------------
ALTER TABLE [dbo].[WorkflowSettings] ADD PRIMARY KEY CLUSTERED ([Id])
ALTER TABLE [Elsa].[WorkflowSettings] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
INSERT INTO [__EFMigrationsHistory] ([MigrationId], [ProductVersion])
-- ----------------------------
-- Indexes structure for table webhookdefinitions
-- ----------------------------
CREATE NONCLUSTERED INDEX [IX_WebhookDefinition_Description]
ON [Elsa].[WebhookDefinitions] (
[Description] ASC
)
CREATE NONCLUSTERED INDEX [IX_WebhookDefinition_IsEnabled]
ON [Elsa].[WebhookDefinitions] (
[IsEnabled] ASC
)
CREATE NONCLUSTERED INDEX [IX_WebhookDefinition_Name]
ON [Elsa].[WebhookDefinitions] (
[Name] ASC
)
CREATE NONCLUSTERED INDEX [IX_WebhookDefinition_Path]
ON [Elsa].[WebhookDefinitions] (
[Path] ASC
)
CREATE NONCLUSTERED INDEX [IX_WebhookDefinition_PayloadTypeName]
ON [Elsa].[WebhookDefinitions] (
[PayloadTypeName] ASC
)
CREATE NONCLUSTERED INDEX [IX_WebhookDefinition_TenantId]
ON [Elsa].[WebhookDefinitions] (
[TenantId] ASC
)
-- ----------------------------
-- Primary Key structure for table webhookdefinitions
-- ----------------------------
ALTER TABLE [Elsa].[WebhookDefinitions] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
-- ----------------------------
-- Primary Key structure for table secrets
-- ----------------------------
ALTER TABLE [Elsa].[Secrets] ADD PRIMARY KEY CLUSTERED ([Id])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
INSERT INTO [Elsa].[__EFMigrationsHistory] ([MigrationId], [ProductVersion])
VALUES
(N'20210523093427_Initial', '5.0.10'),
(N'20210611200027_Update21', '5.0.10'),
@ -429,4 +512,6 @@ VALUES
(N'20220120204150_Update25', '5.0.10'),
(N'20220512203646_Update28', '5.0.10'),
(N'20210604065041_Initial', '5.0.10'),
(N'20210730112043_Initial', '5.0.10');
(N'20210730112043_Initial', '5.0.10'),
(N'20210604065113_Initial', '5.0.10'),
(N'20230709045349_Initial', '5.0.10');

32
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore.SqlServer/LINGYUN/Abp/Elsa/EntityFrameworkCore/SqlServer/Migrations/SqlServerElsaDataBaseInstaller.cs

@ -58,19 +58,39 @@ public class SqlServerElsaDataBaseInstaller : IElsaDataBaseInstaller, ITransient
await sqlConnection.OpenAsync();
}
var tableParams = _installerOptions.InstallTables.Select((_, index) => $"@Table_{index}").JoinAsString(",");
using (var sqlCommand = new SqlCommand($"SELECT COUNT(1) FROM [sys].[objects] WHERE type=N'U' AND name IN ({tableParams});", sqlConnection))
// 检查 Elsa schema
using (var createSchemaCommand = new SqlCommand(@"
IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name = 'elsa')
BEGIN
EXEC('CREATE SCHEMA elsa');
END", sqlConnection))
{
await createSchemaCommand.ExecuteNonQueryAsync();
}
// 检查表
var tableParams = _installerOptions.InstallTables
.Select((_, index) => $"@Table_{index}")
.JoinAsString(",");
using (var sqlCommand = new SqlCommand($@"
SELECT COUNT(1)
FROM sys.tables t
INNER JOIN sys.schemas s ON t.schema_id = s.schema_id
WHERE s.name = 'elsa'
AND t.name IN ({tableParams});",
sqlConnection))
{
sqlCommand.Parameters.Add("@DataBaseName", SqlDbType.NVarChar).Value = dataBaseName;
for (var index = 0; index < _installerOptions.InstallTables.Count; index++)
{
sqlCommand.Parameters.Add($"@Table_{index}", SqlDbType.NVarChar).Value = _installerOptions.InstallTables[index];
sqlCommand.Parameters.Add($"@Table_{index}", SqlDbType.NVarChar, 128)
.Value = _installerOptions.InstallTables[index];
}
var rowsAffects = await sqlCommand.ExecuteScalarAsync() as int?;
if (rowsAffects > 0)
{
Logger.LogInformation($"The `{dataBaseName}` tables has already exists.");
Logger.LogInformation($"The `{dataBaseName}` tables in elsa schema already exist.");
return;
}
}
@ -100,7 +120,7 @@ public class SqlServerElsaDataBaseInstaller : IElsaDataBaseInstaller, ITransient
}
var checkDataBaseName = "";
using (var sqlCommand = new SqlCommand("SELECT [name] FROM [master].[dbo].[sysdatabases] WHERE [name] = @DataBaseName;", sqlConnection))
using (var sqlCommand = new SqlCommand("SELECT [name] FROM [sys].[databases] WHERE [name] = @DataBaseName;", sqlConnection))
{
var dataBaseParamter = sqlCommand.Parameters.Add("DataBaseName", SqlDbType.NVarChar);
dataBaseParamter.Value = dataBase;

13
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN/Abp/Elsa/EntityFrameworkCore/AbpElsaEntityFrameworkCoreModule.cs

@ -1,8 +1,4 @@
using LINGYUN.Abp.Elsa.EntityFrameworkCore.Migrations;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace LINGYUN.Abp.Elsa.EntityFrameworkCore;
@ -12,11 +8,4 @@ namespace LINGYUN.Abp.Elsa.EntityFrameworkCore;
typeof(AbpEntityFrameworkCoreModule))]
public class AbpElsaEntityFrameworkCoreModule : AbpModule
{
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
// 实现 IElsaStoreMigrator 接口自动初始化数据库
await context.ServiceProvider
.GetService<IElsaDataBaseInstaller>()
?.InstallAsync();
}
}

5
aspnet-core/modules/elsa/LINGYUN.Abp.Elsa.EntityFrameworkCore/LINGYUN/Abp/Elsa/EntityFrameworkCore/Migrations/AbpElsaDataBaseInstallerOptions.cs

@ -13,7 +13,10 @@ public class AbpElsaDataBaseInstallerOptions
"WorkflowDefinitions",
"WorkflowExecutionLogRecords",
"WorkflowInstances",
"Triggers"
"Triggers",
"WorkflowSettings",
"Secrets",
"WebhookDefinitions"
};
}
}

6
aspnet-core/modules/localization-management/LINGYUN.Abp.LocalizationManagement.Domain/LINGYUN/Abp/LocalizationManagement/AbpLocalizationManagementDomainModule.cs

@ -8,6 +8,7 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.AutoMapper;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain;
using Volo.Abp.Domain.Entities.Events.Distributed;
@ -56,7 +57,10 @@ public class AbpLocalizationManagementDomainModule : AbpModule
public override async Task OnApplicationInitializationAsync(ApplicationInitializationContext context)
{
await SaveLocalizationAsync(context);
if (!context.ServiceProvider.IsDataMigrationEnvironment())
{
await SaveLocalizationAsync(context);
}
}
public override Task OnApplicationShutdownAsync(ApplicationShutdownContext context)

5
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/INotificationsDefinitionDbContext.cs

@ -1,4 +1,5 @@
using Volo.Abp.Data;
using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.MultiTenancy;
@ -8,4 +9,6 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore;
[ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)]
public interface INotificationsDefinitionDbContext : IEfCoreDbContext
{
DbSet<NotificationDefinitionGroupRecord> NotificationDefinitionGroupRecords { get; }
DbSet<NotificationDefinitionRecord> NotificationDefinitionRecords { get; }
}

3
aspnet-core/modules/realtime-notifications/LINGYUN.Abp.Notifications.EntityFrameworkCore/LINGYUN/Abp/Notifications/EntityFrameworkCore/NotificationsDefinitionDbContext.cs

@ -9,6 +9,9 @@ namespace LINGYUN.Abp.Notifications.EntityFrameworkCore;
[ConnectionStringName(AbpNotificationsDbProperties.ConnectionStringName)]
public class NotificationsDefinitionDbContext : AbpDbContext<NotificationsDefinitionDbContext>, INotificationsDefinitionDbContext
{
public DbSet<NotificationDefinitionGroupRecord> NotificationDefinitionGroupRecords { get; set; }
public DbSet<NotificationDefinitionRecord> NotificationDefinitionRecords { get; set; }
public NotificationsDefinitionDbContext(DbContextOptions<NotificationsDefinitionDbContext> options)
: base(options)
{

3
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/AbpQuartzMySqlInstallerModule.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.Quartz.SqlInstaller;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
@ -15,5 +16,7 @@ public class AbpQuartzMySqlInstallerModule : AbpModule
{
options.FileSets.AddEmbedded<AbpQuartzMySqlInstallerModule>();
});
context.Services.AddTransient<IQuartzSqlInstaller, MySqlQuartzSqlInstaller>();
}
}

7
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.MySqlInstaller/LINGYUN/Abp/Quartz/MySqlInstaller/MySqlQuartzSqlInstaller.cs

@ -17,7 +17,7 @@ using static Quartz.SchedulerBuilder;
namespace LINGYUN.Abp.Quartz.MySqlInstaller;
public class MySqlQuartzSqlInstaller : IQuartzSqlInstaller, ITransientDependency
public class MySqlQuartzSqlInstaller : IQuartzSqlInstaller
{
public ILogger<MySqlQuartzSqlInstaller> Logger { protected get; set; }
@ -40,6 +40,11 @@ public class MySqlQuartzSqlInstaller : IQuartzSqlInstaller, ITransientDependency
Logger = NullLogger<MySqlQuartzSqlInstaller>.Instance;
}
public bool CanInstall(string driverDelegateType)
{
return "Quartz.Impl.AdoJobStore.MySQLDelegate,Quartz".Equals(driverDelegateType);
}
public async virtual Task InstallAsync()
{
var dataSource = _quartzOptions.Properties["quartz.jobStore.dataSource"] ?? AdoProviderOptions.DefaultDataSourceName;

3
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/FodyWeavers.xml

@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<ConfigureAwait ContinueOnCapturedContext="false" />
</Weavers>

30
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/FodyWeavers.xsd

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1">
<xs:complexType>
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" />
</xs:complexType>
</xs:element>
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>

30
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN.Abp.Quartz.PostgresSqlInstaller.csproj

@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\..\..\configureawait.props" />
<Import Project="..\..\..\..\common.props" />
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<AssemblyName>LINGYUN.Abp.Quartz.PostgresInstaller</AssemblyName>
<PackageId>LINGYUN.Abp.Quartz.PostgresInstaller</PackageId>
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<None Remove="LINGYUN\Abp\Quartz\PostgresSqlInstaller\Scripts\Initial.sql" />
<EmbeddedResource Include="LINGYUN\Abp\Quartz\PostgresSqlInstaller\Scripts\Initial.sql" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.VirtualFileSystem" />
<PackageReference Include="Npgsql" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LINGYUN.Abp.Quartz.SqlInstaller\LINGYUN.Abp.Quartz.SqlInstaller.csproj" />
</ItemGroup>
</Project>

22
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN/Abp/Quartz/PostgresSqlInstaller/AbpQuartzPostgresSqlInstallerModule.cs

@ -0,0 +1,22 @@
using LINGYUN.Abp.Quartz.SqlInstaller;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace LINGYUN.Abp.Quartz.PostgresSqlInstaller;
[DependsOn(
typeof(AbpQuartzSqlInstallerModule),
typeof(AbpVirtualFileSystemModule))]
public class AbpQuartzPostgresSqlInstallerModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpQuartzPostgresSqlInstallerModule>();
});
context.Services.AddTransient<IQuartzSqlInstaller, PostgresSqlQuartzSqlInstaller>();
}
}

189
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN/Abp/Quartz/PostgresSqlInstaller/PostgresSqlQuartzSqlInstaller.cs

@ -0,0 +1,189 @@
using LINGYUN.Abp.Quartz.SqlInstaller;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Npgsql;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Quartz;
using Volo.Abp.VirtualFileSystem;
using static Quartz.SchedulerBuilder;
namespace LINGYUN.Abp.Quartz.PostgresSqlInstaller;
public class PostgresSqlQuartzSqlInstaller : IQuartzSqlInstaller
{
public ILogger<PostgresSqlQuartzSqlInstaller> Logger { protected get; set; }
private readonly IVirtualFileProvider _virtualFileProvider;
private readonly AbpQuartzSqlInstallerOptions _installerOptions;
private readonly AbpQuartzOptions _quartzOptions;
private readonly IConfiguration _configuration;
public PostgresSqlQuartzSqlInstaller(
IConfiguration configuration,
IVirtualFileProvider virtualFileProvider,
IOptions<AbpQuartzOptions> quartzOptions,
IOptions<AbpQuartzSqlInstallerOptions> installerOptions)
{
_configuration = configuration;
_quartzOptions = quartzOptions.Value;
_virtualFileProvider = virtualFileProvider;
_installerOptions = installerOptions.Value;
Logger = NullLogger<PostgresSqlQuartzSqlInstaller>.Instance;
}
public bool CanInstall(string driverDelegateType)
{
return "Quartz.Impl.AdoJobStore.PostgreSQLDelegate,Quartz".Equals(driverDelegateType);
}
public async virtual Task InstallAsync()
{
var dataSource = _quartzOptions.Properties["quartz.jobStore.dataSource"] ?? AdoProviderOptions.DefaultDataSourceName;
var connectionString = _quartzOptions.Properties[$"quartz.dataSource.{dataSource}.connectionString"];
var connectionStringName = _quartzOptions.Properties[$"quartz.dataSource.{dataSource}.connectionStringName"];
if (connectionString.IsNullOrWhiteSpace() && !connectionStringName.IsNullOrWhiteSpace())
{
connectionString = _configuration.GetConnectionString(connectionStringName);
}
var tablePrefix = _quartzOptions.Properties["quartz.jobStore.tablePrefix"] ?? "QRTZ_";
if (connectionString.IsNullOrWhiteSpace())
{
Logger.LogWarning($"Please configure the `{dataSource}` database connection string in `quartz.jobStore.dataSource`!");
throw new ArgumentNullException(nameof(connectionString));
}
Logger.LogInformation("Install Quartz PostgreSQL...");
var builder = new NpgsqlConnectionStringBuilder(connectionString);
var dataBaseName = await CreateDataBaseIfNotExists(builder.Database, builder);
builder.Database = dataBaseName;
using var connection = new NpgsqlConnection(builder.ConnectionString);
if (connection.State == ConnectionState.Closed)
{
await connection.OpenAsync();
}
// 检查表是否存在
var tableParams = _installerOptions.InstallTables.Select((_, index) => $"@Table_{index}").JoinAsString(",");
using (var command = new NpgsqlCommand($@"
SELECT COUNT(*) FROM information_schema.tables
WHERE table_catalog = @DataBaseName
AND table_schema = 'public'
AND table_name IN ({tableParams});", connection))
{
command.Parameters.AddWithValue("@DataBaseName", dataBaseName);
for (var index = 0; index < _installerOptions.InstallTables.Count; index++)
{
command.Parameters.AddWithValue($"@Table_{index}", $"{tablePrefix}{_installerOptions.InstallTables[index]}");
}
var rowsAffects = await command.ExecuteScalarAsync() as long?;
if (rowsAffects > 0)
{
Logger.LogInformation($"The `{dataBaseName}` tables has already exists.");
return;
}
}
var sqlScript = await GetInitSqlScript();
// 替换表前缀
sqlScript = sqlScript.Replace("${TablePrefix}", tablePrefix);
// 分割 SQL 脚本,PostgreSQL 需要逐条执行
var sqlCommands = sqlScript.Split(';', StringSplitOptions.RemoveEmptyEntries);
using var transaction = await connection.BeginTransactionAsync();
try
{
foreach (var sqlCommandText in sqlCommands.Where(s => !string.IsNullOrWhiteSpace(s)))
{
using var command = new NpgsqlCommand(sqlCommandText.Trim(), connection, transaction);
Logger.LogDebug($"Executing SQL: {sqlCommandText.Trim().Substring(0, Math.Min(100, sqlCommandText.Trim().Length))}...");
await command.ExecuteNonQueryAsync();
}
await transaction.CommitAsync();
Logger.LogInformation("Database initialization script `Initial.sql` complete!");
}
catch (Exception ex)
{
await transaction.RollbackAsync();
Logger.LogError(ex, "Failed to execute database initialization script!");
throw;
}
}
public async virtual Task<string> CreateDataBaseIfNotExists(string dataBase, NpgsqlConnectionStringBuilder connectionStringBuilder)
{
// PostgreSQL 切换到 template1 数据库来创建新数据库
var originalDatabase = connectionStringBuilder.Database;
// 使用 postgres 系统数据库
connectionStringBuilder.Database = "postgres";
using var connection = new NpgsqlConnection(connectionStringBuilder.ConnectionString);
if (connection.State == ConnectionState.Closed)
{
await connection.OpenAsync();
}
// 检查数据库是否存在
using (var command = new NpgsqlCommand(
"SELECT 1 FROM pg_database WHERE datname = @DataBaseName;", connection))
{
command.Parameters.AddWithValue("@DataBaseName", dataBase);
var exists = await command.ExecuteScalarAsync() != null;
if (!exists)
{
// 创建数据库
using var createCommand = new NpgsqlCommand(
$"CREATE DATABASE \"{dataBase}\" ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = 'en_US.UTF-8' TEMPLATE = template0;",
connection);
await createCommand.ExecuteNonQueryAsync();
Logger.LogInformation($"Database `{dataBase}` created successfully.");
}
}
// 恢复原始数据库连接
connectionStringBuilder.Database = originalDatabase;
return dataBase;
}
public async virtual Task<string> GetInitSqlScript()
{
// 获取数据库初始化脚本
var sqlScriptFileInfo = _virtualFileProvider.GetFileInfo("/LINGYUN/Abp/Quartz/PostgresSqlInstaller/Scripts/Initial.sql");
if (!sqlScriptFileInfo.Exists || sqlScriptFileInfo.IsDirectory)
{
Logger.LogWarning("Please Check that the `Initial.sql` file exists!");
throw new InvalidOperationException("The `Initial.sql` database initialization script file does not exist or is not valid!");
}
var sqlScript = await sqlScriptFileInfo.ReadAsStringAsync();
if (sqlScript.IsNullOrWhiteSpace())
{
Logger.LogWarning("The contents of the `Initial.sql` file are empty or invalid!");
throw new InvalidOperationException("The contents of the `Initial.sql` file are empty or invalid!");
}
return sqlScript;
}
}

180
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.PostgresSqlInstaller/LINGYUN/Abp/Quartz/PostgresSqlInstaller/Scripts/Initial.sql

@ -0,0 +1,180 @@
-- This script is for PostgreSQL
-- This initializes the database to pristine for Quartz, by first removing any existing Quartz tables
-- and then recreating them from scratch.
-- Should you only require it to create the tables, set DropDb to 0.
SET client_min_messages = WARNING;
DROP TABLE IF EXISTS ${TablePrefix}fired_triggers;
DROP TABLE IF EXISTS ${TablePrefix}paused_trigger_grps;
DROP TABLE IF EXISTS ${TablePrefix}scheduler_state;
DROP TABLE IF EXISTS ${TablePrefix}locks;
DROP TABLE IF EXISTS ${TablePrefix}simprop_triggers;
DROP TABLE IF EXISTS ${TablePrefix}simple_triggers;
DROP TABLE IF EXISTS ${TablePrefix}cron_triggers;
DROP TABLE IF EXISTS ${TablePrefix}blob_triggers;
DROP TABLE IF EXISTS ${TablePrefix}triggers;
DROP TABLE IF EXISTS ${TablePrefix}job_details;
DROP TABLE IF EXISTS ${TablePrefix}calendars;
SET client_min_messages = NOTICE;
CREATE TABLE ${TablePrefix}job_details
(
sched_name TEXT NOT NULL,
job_name TEXT NOT NULL,
job_group TEXT NOT NULL,
description TEXT NULL,
job_class_name TEXT NOT NULL,
is_durable BOOL NOT NULL,
is_nonconcurrent BOOL NOT NULL,
is_update_data BOOL NOT NULL,
requests_recovery BOOL NOT NULL,
job_data BYTEA NULL,
PRIMARY KEY (sched_name, job_name, job_group)
);
CREATE TABLE ${TablePrefix}triggers
(
sched_name TEXT NOT NULL,
trigger_name TEXT NOT NULL,
trigger_group TEXT NOT NULL,
job_name TEXT NOT NULL,
job_group TEXT NOT NULL,
description TEXT NULL,
next_fire_time BIGINT NULL,
prev_fire_time BIGINT NULL,
priority INTEGER NULL,
trigger_state TEXT NOT NULL,
trigger_type TEXT NOT NULL,
start_time BIGINT NOT NULL,
end_time BIGINT NULL,
calendar_name TEXT NULL,
misfire_instr SMALLINT NULL,
job_data BYTEA NULL,
PRIMARY KEY (sched_name, trigger_name, trigger_group),
FOREIGN KEY (sched_name, job_name, job_group)
REFERENCES ${TablePrefix}job_details (sched_name, job_name, job_group)
);
CREATE TABLE ${TablePrefix}simple_triggers
(
sched_name TEXT NOT NULL,
trigger_name TEXT NOT NULL,
trigger_group TEXT NOT NULL,
repeat_count BIGINT NOT NULL,
repeat_interval BIGINT NOT NULL,
times_triggered BIGINT NOT NULL,
PRIMARY KEY (sched_name, trigger_name, trigger_group),
FOREIGN KEY (sched_name, trigger_name, trigger_group)
REFERENCES ${TablePrefix}triggers (sched_name, trigger_name, trigger_group)
ON DELETE CASCADE
);
CREATE TABLE ${TablePrefix}simprop_triggers
(
sched_name TEXT NOT NULL,
trigger_name TEXT NOT NULL,
trigger_group TEXT NOT NULL,
str_prop_1 TEXT NULL,
str_prop_2 TEXT NULL,
str_prop_3 TEXT NULL,
int_prop_1 INTEGER NULL,
int_prop_2 INTEGER NULL,
long_prop_1 BIGINT NULL,
long_prop_2 BIGINT NULL,
dec_prop_1 NUMERIC NULL,
dec_prop_2 NUMERIC NULL,
bool_prop_1 BOOL NULL,
bool_prop_2 BOOL NULL,
time_zone_id TEXT NULL,
PRIMARY KEY (sched_name, trigger_name, trigger_group),
FOREIGN KEY (sched_name, trigger_name, trigger_group)
REFERENCES ${TablePrefix}triggers (sched_name, trigger_name, trigger_group)
ON DELETE CASCADE
);
CREATE TABLE ${TablePrefix}cron_triggers
(
sched_name TEXT NOT NULL,
trigger_name TEXT NOT NULL,
trigger_group TEXT NOT NULL,
cron_expression TEXT NOT NULL,
time_zone_id TEXT,
PRIMARY KEY (sched_name, trigger_name, trigger_group),
FOREIGN KEY (sched_name, trigger_name, trigger_group)
REFERENCES ${TablePrefix}triggers (sched_name, trigger_name, trigger_group)
ON DELETE CASCADE
);
CREATE TABLE ${TablePrefix}blob_triggers
(
sched_name TEXT NOT NULL,
trigger_name TEXT NOT NULL,
trigger_group TEXT NOT NULL,
blob_data BYTEA NULL,
PRIMARY KEY (sched_name, trigger_name, trigger_group),
FOREIGN KEY (sched_name, trigger_name, trigger_group)
REFERENCES ${TablePrefix}triggers (sched_name, trigger_name, trigger_group)
ON DELETE CASCADE
);
CREATE TABLE ${TablePrefix}calendars
(
sched_name TEXT NOT NULL,
calendar_name TEXT NOT NULL,
calendar BYTEA NOT NULL,
PRIMARY KEY (sched_name, calendar_name)
);
CREATE TABLE ${TablePrefix}paused_trigger_grps
(
sched_name TEXT NOT NULL,
trigger_group TEXT NOT NULL,
PRIMARY KEY (sched_name, trigger_group)
);
CREATE TABLE ${TablePrefix}fired_triggers
(
sched_name TEXT NOT NULL,
entry_id TEXT NOT NULL,
trigger_name TEXT NOT NULL,
trigger_group TEXT NOT NULL,
instance_name TEXT NOT NULL,
fired_time BIGINT NOT NULL,
sched_time BIGINT NOT NULL,
priority INTEGER NOT NULL,
state TEXT NOT NULL,
job_name TEXT NULL,
job_group TEXT NULL,
is_nonconcurrent BOOL NOT NULL,
requests_recovery BOOL NULL,
PRIMARY KEY (sched_name, entry_id)
);
CREATE TABLE ${TablePrefix}scheduler_state
(
sched_name TEXT NOT NULL,
instance_name TEXT NOT NULL,
last_checkin_time BIGINT NOT NULL,
checkin_interval BIGINT NOT NULL,
PRIMARY KEY (sched_name, instance_name)
);
CREATE TABLE ${TablePrefix}locks
(
sched_name TEXT NOT NULL,
lock_name TEXT NOT NULL,
PRIMARY KEY (sched_name, lock_name)
);
CREATE INDEX idx_${TablePrefix}j_req_recovery ON ${TablePrefix}job_details (requests_recovery);
CREATE INDEX idx_${TablePrefix}t_next_fire_time ON ${TablePrefix}triggers (next_fire_time);
CREATE INDEX idx_${TablePrefix}t_state ON ${TablePrefix}triggers (trigger_state);
CREATE INDEX idx_${TablePrefix}t_nft_st ON ${TablePrefix}triggers (next_fire_time, trigger_state);
CREATE INDEX idx_${TablePrefix}ft_trig_name ON ${TablePrefix}fired_triggers (trigger_name);
CREATE INDEX idx_${TablePrefix}ft_trig_group ON ${TablePrefix}fired_triggers (trigger_group);
CREATE INDEX idx_${TablePrefix}ft_trig_nm_gp ON ${TablePrefix}fired_triggers (sched_name, trigger_name, trigger_group);
CREATE INDEX idx_${TablePrefix}ft_trig_inst_name ON ${TablePrefix}fired_triggers (instance_name);
CREATE INDEX idx_${TablePrefix}ft_job_name ON ${TablePrefix}fired_triggers (job_name);
CREATE INDEX idx_${TablePrefix}ft_job_group ON ${TablePrefix}fired_triggers (job_group);
CREATE INDEX idx_${TablePrefix}ft_job_req_recovery ON ${TablePrefix}fired_triggers (requests_recovery);

1
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN.Abp.Quartz.SqlInstaller.csproj

@ -14,6 +14,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Volo.Abp.Data" />
<PackageReference Include="Volo.Abp.Quartz" />
</ItemGroup>

55
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/AbpQuartzSqlInstallerModule.cs

@ -6,44 +6,59 @@ using Quartz.Simpl;
using Quartz.Util;
using System.Threading.Tasks;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
using Volo.Abp.Quartz;
namespace LINGYUN.Abp.Quartz.SqlInstaller;
[DependsOn(typeof(AbpQuartzModule))]
[DependsOn(
typeof(AbpDataModule),
typeof(AbpQuartzModule))]
public class AbpQuartzSqlInstallerModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
var abpQuartzOptions = context.Services.ExecutePreConfiguredActions<AbpQuartzOptions>();
Configure<QuartzOptions>(options =>
if (!context.Services.IsDataMigrationEnvironment())
{
foreach (var settingKey in abpQuartzOptions.Properties.AllKeys)
var abpQuartzOptions = context.Services.ExecutePreConfiguredActions<AbpQuartzOptions>();
Configure<QuartzOptions>(options =>
{
options[settingKey] = abpQuartzOptions.Properties[settingKey];
}
foreach (var settingKey in abpQuartzOptions.Properties.AllKeys)
{
options[settingKey] = abpQuartzOptions.Properties[settingKey];
}
if (abpQuartzOptions.Properties[StdSchedulerFactory.PropertyJobStoreType] == null)
{
var defaultJobStoreType = typeof(RAMJobStore).AssemblyQualifiedNameWithoutVersion();
if (abpQuartzOptions.Properties[StdSchedulerFactory.PropertyJobStoreType] == null)
{
var defaultJobStoreType = typeof(RAMJobStore).AssemblyQualifiedNameWithoutVersion();
options[StdSchedulerFactory.PropertyJobStoreType] = defaultJobStoreType;
abpQuartzOptions.Properties[StdSchedulerFactory.PropertyJobStoreType] = defaultJobStoreType;
}
});
options[StdSchedulerFactory.PropertyJobStoreType] = defaultJobStoreType;
abpQuartzOptions.Properties[StdSchedulerFactory.PropertyJobStoreType] = defaultJobStoreType;
}
});
}
}
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (configuration.GetValue("Quartz:UsePersistentStore", false) &&
!configuration[$"Quartz:Properties:{StdSchedulerFactory.PropertyJobStoreType}"].IsNullOrWhiteSpace())
if (!context.ServiceProvider.IsDataMigrationEnvironment())
{
// 初始化 Quartz 数据库
await context.ServiceProvider
.GetService<IQuartzSqlInstaller>()
?.InstallAsync();
var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
if (configuration.GetValue("Quartz:UsePersistentStore", false))
{
var driverDelegateType = configuration[$"Quartz:Properties:quartz.jobStore.driverDelegateType"];
// 初始化 Quartz 数据库
var installs = context.ServiceProvider.GetServices<IQuartzSqlInstaller>();
foreach (var install in installs)
{
if (install.CanInstall(driverDelegateType))
{
await install.InstallAsync();
}
}
}
}
}
}

2
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlInstaller/LINGYUN/Abp/Quartz/SqlInstaller/IQuartzSqlInstaller.cs

@ -4,5 +4,7 @@ namespace LINGYUN.Abp.Quartz.SqlInstaller;
public interface IQuartzSqlInstaller
{
bool CanInstall(string driverDelegateType);
Task InstallAsync();
}

3
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/AbpQuartzSqlServerInstallerModule.cs

@ -1,4 +1,5 @@
using LINGYUN.Abp.Quartz.SqlInstaller;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
@ -15,5 +16,7 @@ public class AbpQuartzSqlServerInstallerModule : AbpModule
{
options.FileSets.AddEmbedded<AbpQuartzSqlServerInstallerModule>();
});
context.Services.AddTransient<IQuartzSqlInstaller, SqlServerQuartzSqlInstaller>();
}
}

7
aspnet-core/modules/task-management/LINGYUN.Abp.Quartz.SqlServerInstaller/LINGYUN/Abp/Quartz/SqlServerInstaller/SqlServerQuartzSqlInstaller.cs

@ -16,7 +16,7 @@ using static Quartz.SchedulerBuilder;
namespace LINGYUN.Abp.Quartz.SqlServerInstaller;
public class SqlServerQuartzSqlInstaller : IQuartzSqlInstaller, ITransientDependency
public class SqlServerQuartzSqlInstaller : IQuartzSqlInstaller
{
public ILogger<SqlServerQuartzSqlInstaller> Logger { protected get; set; }
@ -36,6 +36,11 @@ public class SqlServerQuartzSqlInstaller : IQuartzSqlInstaller, ITransientDepend
Logger = NullLogger<SqlServerQuartzSqlInstaller>.Instance;
}
public bool CanInstall(string driverDelegateType)
{
return "Quartz.Impl.AdoJobStore.SqlServerDelegate,Quartz".Equals(driverDelegateType);
}
public async virtual Task InstallAsync()
{
var dataSource = _quartzOptions.Properties["quartz.jobStore.dataSource"] ?? AdoProviderOptions.DefaultDataSourceName;

8
aspnet-core/services/LY.MicroService.Applications.Single/GlobalUsings.cs

@ -34,6 +34,7 @@ global using LINGYUN.Abp.Demo.EntityFrameworkCore;
global using LINGYUN.Abp.Demo.Localization;
global using LINGYUN.Abp.Elsa;
global using LINGYUN.Abp.Elsa.Activities;
global using LINGYUN.Abp.Elsa.Designer;
global using LINGYUN.Abp.Elsa.EntityFrameworkCore;
global using LINGYUN.Abp.EventBus.CAP;
global using LINGYUN.Abp.ExceptionHandling;
@ -119,7 +120,10 @@ global using LINGYUN.Abp.WeChat.Official;
global using LINGYUN.Abp.WeChat.Official.Handlers;
global using LINGYUN.Abp.WeChat.SettingManagement;
global using LINGYUN.Abp.WeChat.Work;
global using LINGYUN.Abp.WeChat.Work.Contacts;
global using LINGYUN.Abp.WeChat.Work.ExternalContact;
global using LINGYUN.Abp.WeChat.Work.Handlers;
global using LINGYUN.Abp.WeChat.Work.OA;
global using LINGYUN.Abp.Wrapper;
global using LINGYUN.Platform;
global using LINGYUN.Platform.EntityFrameworkCore;
@ -129,6 +133,8 @@ global using LINGYUN.Platform.Settings.VueVbenAdmin;
global using LINGYUN.Platform.Theme.VueVbenAdmin;
global using LY.MicroService.Applications.Single.Bundling;
global using LY.MicroService.Applications.Single.EntityFrameworkCore.MySql;
global using LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql;
global using LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer;
//global using LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer;
global using LY.MicroService.Applications.Single.Messages;
global using Medallion.Threading;
@ -166,8 +172,6 @@ global using Volo.Abp.Auditing;
global using Volo.Abp.Authorization.Permissions;
global using Volo.Abp.Autofac;
global using Volo.Abp.BlobStoring;
global using Volo.Abp.BlobStoring.FileSystem;
global using Volo.Abp.BlobStoring.Minio;
global using Volo.Abp.Caching;
global using Volo.Abp.Caching.StackExchangeRedis;
global using Volo.Abp.Data;

3
aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj

@ -126,7 +126,8 @@
<ItemGroup>
<ProjectReference Include="..\..\migrations\LY.MicroService.Applications.Single.EntityFrameworkCore.MySql\LY.MicroService.Applications.Single.EntityFrameworkCore.MySql.csproj" />
<!--<ProjectReference Include="..\..\migrations\LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer\LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer.csproj" />-->
<ProjectReference Include="..\..\migrations\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj" />
<ProjectReference Include="..\..\migrations\LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer\LY.MicroService.Applications.Single.EntityFrameworkCore.SqlServer.csproj" />
</ItemGroup>
<ItemGroup>

13
aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs

@ -45,15 +45,10 @@ public partial class MicroServiceApplicationsSingleModule
.UseRedis(configuration["CAP:Redis:Configuration"]);
return;
}
options
.UseMySql(mySqlOptions =>
{
configuration.GetSection("CAP:MySql").Bind(mySqlOptions);
})
.UseRabbitMQ(rabbitMQOptions =>
{
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions);
});
options.UseRabbitMQ(rabbitMQOptions =>
{
configuration.GetSection("CAP:RabbitMQ").Bind(rabbitMQOptions);
});
});
}

15
aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs

@ -1,8 +1,3 @@
using LINGYUN.Abp.Elsa.Designer;
using LINGYUN.Abp.WeChat.Work.Contacts;
using LINGYUN.Abp.WeChat.Work.ExternalContact;
using LINGYUN.Abp.WeChat.Work.OA;
namespace LY.MicroService.Applications.Single;
[DependsOn(
@ -387,10 +382,12 @@ namespace LY.MicroService.Applications.Single;
typeof(AbpMailKitModule),
typeof(AbpAutofacModule),
// 取消注释使用MySql
typeof(SingleMigrationsEntityFrameworkCoreMySqlModule)
// 取消注释使用SqlServer
//typeof(SingleMigrationsEntityFrameworkCoreSqlServerModule)
// MySql
typeof(SingleMigrationsEntityFrameworkCoreMySqlModule),
// SqlServer
typeof(SingleMigrationsEntityFrameworkCoreSqlServerModule),
// PostgreSql
typeof(SingleMigrationsEntityFrameworkCorePostgreSqlModule)
)]
public partial class MicroServiceApplicationsSingleModule : AbpModule
{

9
aspnet-core/services/LY.MicroService.Applications.Single/Program.cs

@ -6,17 +6,18 @@ using Volo.Abp.Modularity.PlugIns;
var builder = WebApplication.CreateBuilder(args);
builder.Host.AddAppSettingsSecretsJson()
.UseAutofac()
.ConfigureAppConfiguration((context, config) =>
.ConfigureAppConfiguration((context, builder) =>
{
var env = context.HostingEnvironment.EnvironmentName;
var dbProvider = Environment.GetEnvironmentVariable("APPLICATION_DATABASE_PROVIDER");
if (!dbProvider.IsNullOrWhiteSpace())
if (!dbProvider.IsNullOrWhiteSpace() && !env.IsNullOrWhiteSpace())
{
config.AddJsonFile($"appsettings.{dbProvider}.json", optional: true);
builder.AddJsonFile($"appsettings.{env}.{dbProvider}.json", optional: true);
}
if (context.Configuration.GetValue("AgileConfig:IsEnabled", false))
{
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration));
builder.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration));
}
})
.UseSerilog((context, provider, config) =>

10
aspnet-core/services/LY.MicroService.Applications.Single/Properties/launchSettings.json

@ -8,6 +8,16 @@
}
},
"profiles": {
"Single.PostgreSql.Dev": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://0.0.0.0:30001",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"APPLICATION_DATABASE_PROVIDER": "PostgreSql"
}
},
"Single.MySql.Dev": {
"commandName": "Project",
"dotnetRunMessages": true,

63
aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.MySql.json

@ -0,0 +1,63 @@
{
"CAP": {
"MySql": {
"TableNamePrefix": "pt_event",
"ConnectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None"
}
},
"Quartz": {
"UsePersistentStore": true,
"Properties": {
"quartz.jobStore.dataSource": "tkm",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.MySQLDelegate,Quartz",
"quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"quartz.dataSource.tkm.connectionStringName": "Default",
"quartz.dataSource.tkm.provider": "MySqlConnector",
"quartz.jobStore.clustered": "true",
"quartz.serializer.type": "json"
}
},
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"AbpSaas": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"AbpTextTemplating": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"Workflow": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None"
},
"Elsa": {
"Features": {
"DefaultPersistence": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"MySql": {
"Enabled": true
}
}
},
"Webhooks": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"MySql": {
"Enabled": true
}
}
},
"WorkflowSettings": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"MySql": {
"Enabled": true
}
}
}
}
}
}

63
aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.PostgreSql.json

@ -0,0 +1,63 @@
{
"CAP": {
"PostgreSql": {
"TableNamePrefix": "pt_event",
"ConnectionString": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer"
}
},
"Quartz": {
"UsePersistentStore": true,
"Properties": {
"quartz.jobStore.dataSource": "tkm",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.PostgreSQLDelegate,Quartz",
"quartz.dataSource.tkm.connectionString": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"quartz.dataSource.tkm.connectionStringName": "TaskManagement",
"quartz.dataSource.tkm.provider": "Npgsql",
"quartz.jobStore.clustered": "true",
"quartz.serializer.type": "json"
}
},
"ConnectionStrings": {
"Default": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"AbpSaas": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"AbpTenantManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"AbpSettingManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"AbpPermissionManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"AbpFeatureManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"AbpTextTemplating": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"AbpLocalizationManagement": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer",
"Workflow": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;SslMode=Prefer"
},
"Elsa": {
"Features": {
"DefaultPersistence": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"PostgreSql": {
"Enabled": true
}
}
},
"Webhooks": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"PostgreSql": {
"Enabled": true
}
}
},
"WorkflowSettings": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"PostgreSql": {
"Enabled": true
}
}
}
}
}
}

63
aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.SqlServer.json

@ -0,0 +1,63 @@
{
"CAP": {
"SqlServer": {
"TableNamePrefix": "pt_event",
"ConnectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false"
}
},
"Quartz": {
"UsePersistentStore": true,
"Properties": {
"quartz.jobStore.dataSource": "tkm",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.SqlServerDelegate,Quartz",
"quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"quartz.dataSource.tkm.connectionStringName": "Default",
"quartz.dataSource.tkm.provider": "SqlServer",
"quartz.jobStore.clustered": "true",
"quartz.serializer.type": "json"
}
},
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"AbpSaas": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"AbpTextTemplating": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false",
"Workflow": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=123456;Encrypt=false"
},
"Elsa": {
"Features": {
"DefaultPersistence": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"SqlServer": {
"Enabled": true
}
}
},
"Webhooks": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"SqlServer": {
"Enabled": true
}
}
},
"WorkflowSettings": {
"Enabled": true,
"ConnectionStringIdentifier": "Workflow",
"EntityFrameworkCore": {
"SqlServer": {
"Enabled": true
}
}
}
}
}
}

45
aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.json

@ -37,10 +37,6 @@
"FailedRetryInterval": 300,
"FailedRetryCount": 10
},
"MySql": {
"TableNamePrefix": "pt_event",
"ConnectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None"
},
"RabbitMQ": {
"HostName": "127.0.0.1",
"Port": 5672,
@ -61,9 +57,6 @@
"AbsoluteExpirationRelativeToNow": "60:00:00"
}
},
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None"
},
"DistributedLock": {
"IsEnabled": true,
"Redis": {
@ -72,15 +65,6 @@
},
"Elsa": {
"Features": {
"DefaultPersistence": {
"Enabled": true,
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"MySql": {
"Enabled": true
}
}
},
"Console": true,
"Http": true,
"Email": true,
@ -94,25 +78,7 @@
"Notification": true,
"Sms": true,
"IM": true,
"PublishWebhook": true,
"Webhooks": {
"Enabled": true,
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"MySql": {
"Enabled": true
}
}
},
"WorkflowSettings": {
"Enabled": true,
"ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": {
"MySql": {
"Enabled": true
}
}
}
"PublishWebhook": true
},
"Server": {
"BaseUrl": "http://127.0.0.1:30001"
@ -121,12 +87,6 @@
"Quartz": {
"UsePersistentStore": true,
"Properties": {
"quartz.jobStore.dataSource": "tkm",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.MySQLDelegate,Quartz",
"quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None",
"quartz.dataSource.tkm.connectionStringName": "Default",
"quartz.dataSource.tkm.provider": "MySqlConnector",
"quartz.jobStore.clustered": "true",
"quartz.serializer.type": "json"
}
@ -169,7 +129,8 @@
"RootUrl": "http://127.0.0.1:3100/"
},
"InternalService": {
"ClientId": "InternalServiceClient"
"ClientId": "InternalServiceClient",
"ClientSecret": "1q2w3e*"
},
"VueOAuthClient": {
"ClientId": "vue-oauth-client",

23
aspnet-core/services/LY.MicroService.Applications.Single/appsettings.SqlServer.json

@ -1,23 +0,0 @@
{
"ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=P@ssw@rd!;Encrypt=false"
},
"CAP": {
"SqlServer": {
"TableNamePrefix": "pt_event",
"ConnectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=P@ssw@rd!;Encrypt=false"
}
},
"Quartz": {
"Properties": {
"quartz.jobStore.dataSource": "tkm",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.SqlServerDelegate,Quartz",
"quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=sa;Password=P@ssw@rd!;Encrypt=false",
"quartz.dataSource.tkm.provider": "SqlServer",
"quartz.jobStore.clustered": true,
"quartz.checkConfiguration": "false",
"quartz.serializer.type": "json"
}
}
}

1
aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/LY.MicroService.TaskManagement.HttpApi.Host.csproj

@ -66,7 +66,6 @@
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.Jobs\LINGYUN.Abp.BackgroundTasks.Jobs.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.Notifications\LINGYUN.Abp.BackgroundTasks.Notifications.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.BackgroundTasks.Quartz\LINGYUN.Abp.BackgroundTasks.Quartz.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.Quartz.MySqlInstaller\LINGYUN.Abp.Quartz.MySqlInstaller.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.TaskManagement.Application\LINGYUN.Abp.TaskManagement.Application.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.TaskManagement.EntityFrameworkCore\LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\task-management\LINGYUN.Abp.TaskManagement.HttpApi\LINGYUN.Abp.TaskManagement.HttpApi.csproj" />

1
aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Program.cs

@ -26,6 +26,7 @@ public class Program
.UseAutofac()
.ConfigureAppConfiguration((context, config) =>
{
// AgileConfig 分布式配置平台, 顺序排在最后可覆盖所有本地配置文件
if (context.Configuration.GetValue("AgileConfig:IsEnabled", false))
{
config.AddAgileConfig(new AgileConfig.Client.ConfigClient(context.Configuration));

2
aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/Properties/launchSettings.json

@ -8,7 +8,7 @@
}
},
"profiles": {
"LY.MicroService.TaskManagement.HttpApi.Host": {
"Dev.Default": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,

2
aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/TaskManagementHttpApiHostModule.cs

@ -16,7 +16,6 @@ using LINGYUN.Abp.ExceptionHandling.Emailing;
using LINGYUN.Abp.Localization.CultureMap;
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore;
using LINGYUN.Abp.OssManagement;
using LINGYUN.Abp.Quartz.MySqlInstaller;
using LINGYUN.Abp.Saas.EntityFrameworkCore;
using LINGYUN.Abp.Serilog.Enrichers.Application;
using LINGYUN.Abp.Serilog.Enrichers.UniqueId;
@ -65,7 +64,6 @@ namespace LY.MicroService.TaskManagement;
typeof(AbpBackgroundTasksDistributedLockingModule),
typeof(AbpBackgroundTasksExceptionHandlingModule),
typeof(AbpBackgroundTasksNotificationsModule),
typeof(AbpQuartzMySqlInstallerModule),
typeof(TaskManagementApplicationModule),
typeof(TaskManagementHttpApiModule),
typeof(TaskManagementEntityFrameworkCoreModule),

10
aspnet-core/services/LY.MicroService.TaskManagement.HttpApi.Host/appsettings.Development.json

@ -61,9 +61,13 @@
},
"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"
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"AbpTenantManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"AbpTextTemplating": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None",
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456;SslMode=None"
},
"RemoteServices": {
"AbpOssManagement": {

36
docs/startup-aio-readme.md

@ -112,7 +112,7 @@ dotnet run --launch-profile "YourPackageName.YourCompanyName.YourProjectName.Dev
# 使用Docker启动PostgreSQL
docker run -d --name postgres \
-p 5432:5432 \
-e POSTGRES_PASSWORD=postgres \
-e POSTGRES_PASSWORD=123456 \
-e PGDATA=/var/lib/postgresql/data \
postgres:latest
```
@ -123,16 +123,10 @@ docker run -d --name postgres \
# 使用Docker启动MySQL
docker run -d --name mysql \
-p 3306:3306 \
-e MYSQL_ROOT_PASSWORD=mysql \
-e MYSQL_ROOT_PASSWORD=123456 \
mysql:latest
```
创建数据库:
```sql
CREATE DATABASE `Platform-V70`;
```
##### SQL Server
```shell
@ -140,7 +134,7 @@ CREATE DATABASE `Platform-V70`;
docker run -d --name sqlserver \
-p 1433:1433 \
-e "ACCEPT_EULA=Y" \
-e "SA_PASSWORD=yourStrong(!)Password" \
-e "SA_PASSWORD=123456" \
mcr.microsoft.com/mssql/server:latest
```
@ -148,13 +142,11 @@ docker run -d --name sqlserver \
需要根据选择的数据库类型修改以下配置文件中的数据库连接字符串:
- `migrations/LY.MicroService.Applications.Single.DbMigrator/appsettings.json`
- `LY.MicroService.Applications.Single/appsettings.Development.json`
数据库连接字符串示例:
PostgreSQL:
- `LY.MicroService.Applications.Single/appsettings.Development.PostgreSql.json`
```json
{
"ConnectionStrings": {
@ -165,6 +157,7 @@ PostgreSQL:
MySQL:
- `LY.MicroService.Applications.Single/appsettings.Development.MySql.json`
```json
{
"ConnectionStrings": {
@ -175,10 +168,11 @@ MySQL:
SQL Server:
- `LY.MicroService.Applications.Single/appsettings.Development.SqlServer.json`
```json
{
"ConnectionStrings": {
"Default": "Server=localhost,1433;Database=Platform-V70;User Id=sa;Password=yourStrong(!)Password;TrustServerCertificate=True"
"Default": "Server=localhost,1433;Database=Platform-V70;User Id=sa;Password=123456;TrustServerCertificate=True"
}
}
```
@ -249,7 +243,7 @@ Redis 配置示例:
1. 运行数据库迁移脚本:
方案一(推荐)
方案一:
```shell
./aspnet-core/migrations/Migrate.ps1
@ -257,25 +251,23 @@ Redis 配置示例:
根据命令行提示生成迁移文件和 sql 脚本,然后执行 sql 脚本来创建数据表
方案二:
方案二(推荐)
以 pgsql 为例
- 修改 `LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json` 中的数据库连接信息
- 进入`LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql`项目
- 运行 `dotnet ef database update`
- 等待数据迁移完成
1. 选择启动配置
- 选择 `LY.MicroService.Applications.Single.DbMigrator/Properties/launchSettings.json` 中的 `Single.PostgreSql.Dev`
2. 配置数据初始化:
- 修改 `LY.MicroService.Applications.Single.DbMigrator/appsettings.json` 中的数据库连接信息
- 确保选择了正确的数据库提供程序
- 修改 `LY.MicroService.Applications.Single.DbMigrator/appsettings.PostgreSql.json` 中的数据库连接信息
3. 执行数据迁移:
- 运行 `LY.MicroService.Applications.Single.DbMigrator` 项目
- 等待数据迁移完成,基础表数据将被初始化
### 服务启动
1. 选择启动配置
- 选择 `LY.MicroService.Applications.Single/Properties/launchSettings.json` 中的 `Single.PostgreSql.Dev`
1. 运行 `LY.MicroService.Applications.Single` 项目
2. 在浏览器中访问 Swagger 接口文档:
- URL: http://127.0.0.1:30000/swagger

Loading…
Cancel
Save