Browse Source

🔧 refactor(数据库迁移模块): 移除对MySQL和PostgreSQL的条件编译指令,简化代码结构

pull/1049/head
feijie 1 year ago
parent
commit
ff5c038541
  1. 501
      aspnet-core/LINGYUN.MicroService.SingleProject.sln
  2. 8
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/LY.MicroService.Applications.Single.DbMigrator.csproj
  3. 10
      aspnet-core/migrations/LY.MicroService.Applications.Single.DbMigrator/SingleDbMigratorModule.cs
  4. 15
      aspnet-core/services/LY.MicroService.Applications.Single/LY.MicroService.Applications.Single.csproj
  5. 9
      aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.Configure.cs
  6. 28
      aspnet-core/services/LY.MicroService.Applications.Single/MicroServiceApplicationsSingleModule.cs
  7. 9
      aspnet-core/services/LY.MicroService.Applications.Single/Properties/launchSettings.json
  8. 20
      aspnet-core/services/LY.MicroService.Applications.Single/appsettings.Development.json
  9. 2
      aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj
  10. 2
      aspnet-core/tests/LINGYUN.Abp.IP2Region.Tests/LINGYUN.Abp.IP2Region.Tests.csproj
  11. 2
      aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj

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

File diff suppressed because it is too large

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

@ -7,12 +7,6 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<Configurations>Debug;Release;PostgreSQL</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='PostgreSQL|AnyCPU'">
<DefineConstants>POSTGRESQL</DefineConstants>
<OutputPath>bin\Debug/</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -64,7 +58,7 @@
<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.VueVbenAdmin\LINGYUN.Abp.UI.Navigation.VueVbenAdmin.csproj" />
<ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj" /> <ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql\LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql.csproj" />
<ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore\LY.MicroService.Applications.Single.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\LY.MicroService.Applications.Single.EntityFrameworkCore.MySql\LY.MicroService.Applications.Single.EntityFrameworkCore.Mysql.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

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

@ -1,10 +1,7 @@
using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; using LINGYUN.Abp.UI.Navigation.VueVbenAdmin;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
#if POSTGRESQL
using LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql; using LY.MicroService.Applications.Single.EntityFrameworkCore.PostgreSql;
#else // using LY.MicroService.Applications.Single.EntityFrameworkCore.MySql;
using LY.MicroService.Applications.Single.EntityFrameworkCore;
#endif
using Volo.Abp.Autofac; using Volo.Abp.Autofac;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
@ -12,11 +9,8 @@ namespace LY.MicroService.Applications.Single.DbMigrator;
[DependsOn( [DependsOn(
typeof(AbpUINavigationVueVbenAdminModule), typeof(AbpUINavigationVueVbenAdminModule),
#if POSTGRESQL
typeof(SingleMigrationsEntityFrameworkCorePostgreSqlModule), typeof(SingleMigrationsEntityFrameworkCorePostgreSqlModule),
#else // typeof(SingleMigrationsEntityFrameworkCoreMySqlModule),
typeof(SingleMigrationsEntityFrameworkCoreModule),
#endif
typeof(AbpAutofacModule) typeof(AbpAutofacModule)
)] )]
public partial class SingleDbMigratorModule : AbpModule public partial class SingleDbMigratorModule : AbpModule

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

@ -6,12 +6,6 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>LY.MicroService.Applications.Single</RootNamespace> <RootNamespace>LY.MicroService.Applications.Single</RootNamespace>
<Configurations>Debug;Release;PostgreSQL</Configurations>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='PostgreSQL|AnyCPU'">
<DefineConstants>POSTGRESQL</DefineConstants>
<OutputPath>bin\Debug/</OutputPath>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -43,8 +37,8 @@
<PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" /> <PackageReference Include="Volo.Abp.AspNetCore.Authentication.JwtBearer" />
<PackageReference Include="Volo.Abp.Autofac" /> <PackageReference Include="Volo.Abp.Autofac" />
<PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" /> <PackageReference Include="Volo.Abp.Caching.StackExchangeRedis" />
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" Condition="'$(Configuration)' != 'PostgreSQL'" /> <!-- <PackageReference Include="Volo.Abp.EntityFrameworkCore.MySQL" />-->
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Condition="'$(Configuration)' == 'PostgreSQL'" /> <PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" />
<PackageReference Include="Volo.Abp.FeatureManagement.Application" /> <PackageReference Include="Volo.Abp.FeatureManagement.Application" />
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" /> <PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" />
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" /> <PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" />
@ -119,7 +113,6 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\..\migrations\LY.MicroService.Applications.Single.EntityFrameworkCore\LY.MicroService.Applications.Single.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application.Contracts\LINGYUN.Abp.Account.Application.Contracts.csproj" /> <ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application.Contracts\LINGYUN.Abp.Account.Application.Contracts.csproj" />
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application\LINGYUN.Abp.Account.Application.csproj" /> <ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.Application\LINGYUN.Abp.Account.Application.csproj" />
<ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.HttpApi\LINGYUN.Abp.Account.HttpApi.csproj" /> <ProjectReference Include="..\..\modules\account\LINGYUN.Abp.Account.HttpApi\LINGYUN.Abp.Account.HttpApi.csproj" />
@ -145,8 +138,8 @@
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Activities.Sms\LINGYUN.Abp.Elsa.Activities.Sms.csproj" /> <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Activities.Sms\LINGYUN.Abp.Elsa.Activities.Sms.csproj" />
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Activities.Webhooks\LINGYUN.Abp.Elsa.Activities.Webhooks.csproj" /> <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Activities.Webhooks\LINGYUN.Abp.Elsa.Activities.Webhooks.csproj" />
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Activities\LINGYUN.Abp.Elsa.Activities.csproj" /> <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Activities\LINGYUN.Abp.Elsa.Activities.csproj" />
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj" Condition="'$(Configuration)' != 'PostgreSQL'" /> <!-- <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql\LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql.csproj" />-->
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql\LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql.csproj" Condition="'$(Configuration)' == 'PostgreSQL'" /> <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql\LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql.csproj" />
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore\LINGYUN.Abp.Elsa.EntityFrameworkCore.csproj" /> <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.EntityFrameworkCore\LINGYUN.Abp.Elsa.EntityFrameworkCore.csproj" />
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Server\LINGYUN.Abp.Elsa.Server.csproj" /> <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa.Server\LINGYUN.Abp.Elsa.Server.csproj" />
<ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj" /> <ProjectReference Include="..\..\modules\elsa\LINGYUN.Abp.Elsa\LINGYUN.Abp.Elsa.csproj" />

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

@ -570,13 +570,10 @@ public partial class MicroServiceApplicationsSingleModule
{ {
Configure<AbpDbContextOptions>(options => Configure<AbpDbContextOptions>(options =>
{ {
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);//解决PostgreSql设置为utc时间后无法写入local时区的问题
#if POSTGRESQL
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
options.UseNpgsql(); options.UseNpgsql();
#else
options.UseMySQL(); // options.UseMySQL();
#endif
}); });
} }

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

@ -29,13 +29,10 @@ using LINGYUN.Abp.Demo.EntityFrameworkCore;
using LINGYUN.Abp.Elsa; using LINGYUN.Abp.Elsa;
using LINGYUN.Abp.Elsa.Activities; using LINGYUN.Abp.Elsa.Activities;
using LINGYUN.Abp.Elsa.EntityFrameworkCore; using LINGYUN.Abp.Elsa.EntityFrameworkCore;
#if POSTGRESQL
using Volo.Abp.EntityFrameworkCore.PostgreSql; using Volo.Abp.EntityFrameworkCore.PostgreSql;
using LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql; using LINGYUN.Abp.Elsa.EntityFrameworkCore.PostgreSql;
#else // using LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql;
using LINGYUN.Abp.Elsa.EntityFrameworkCore.MySql; // using Volo.Abp.EntityFrameworkCore.MySQL;
using Volo.Abp.EntityFrameworkCore.MySQL;
#endif
using LINGYUN.Abp.ExceptionHandling; using LINGYUN.Abp.ExceptionHandling;
using LINGYUN.Abp.ExceptionHandling.Emailing; using LINGYUN.Abp.ExceptionHandling.Emailing;
using LINGYUN.Abp.Exporter.MiniExcel; using LINGYUN.Abp.Exporter.MiniExcel;
@ -113,7 +110,6 @@ using LINGYUN.Platform.EntityFrameworkCore;
using LINGYUN.Platform.HttpApi; using LINGYUN.Platform.HttpApi;
using LINGYUN.Platform.Settings.VueVbenAdmin; using LINGYUN.Platform.Settings.VueVbenAdmin;
using LINGYUN.Platform.Theme.VueVbenAdmin; using LINGYUN.Platform.Theme.VueVbenAdmin;
using LY.MicroService.Applications.Single.EntityFrameworkCore;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Account.Web; using Volo.Abp.Account.Web;
using Volo.Abp.AspNetCore.Authentication.JwtBearer; using Volo.Abp.AspNetCore.Authentication.JwtBearer;
@ -242,12 +238,8 @@ namespace LY.MicroService.Applications.Single;
typeof(AbpPermissionManagementEntityFrameworkCoreModule), typeof(AbpPermissionManagementEntityFrameworkCoreModule),
typeof(AbpPermissionManagementDomainOrganizationUnitsModule), // 组织机构权限管理 typeof(AbpPermissionManagementDomainOrganizationUnitsModule), // 组织机构权限管理
typeof(SingleMigrationsEntityFrameworkCoreModule),
#if POSTGRESQL
typeof(AbpEntityFrameworkCorePostgreSqlModule), typeof(AbpEntityFrameworkCorePostgreSqlModule),
#else // typeof(AbpEntityFrameworkCoreMySQLModule),
typeof(AbpEntityFrameworkCoreMySQLModule),
#endif
typeof(AbpAliyunSmsModule), typeof(AbpAliyunSmsModule),
typeof(AbpAliyunSettingManagementModule), typeof(AbpAliyunSettingManagementModule),
@ -316,20 +308,16 @@ namespace LY.MicroService.Applications.Single;
typeof(AbpAccountTemplatesModule), typeof(AbpAccountTemplatesModule),
typeof(AbpAspNetCoreAuthenticationJwtBearerModule), typeof(AbpAspNetCoreAuthenticationJwtBearerModule),
typeof(AbpCachingStackExchangeRedisModule), typeof(AbpCachingStackExchangeRedisModule),
#if POSTGRESQL
// typeof(AbpElsaModule), // typeof(AbpElsaModule),
// typeof(AbpElsaServerModule), // typeof(AbpElsaServerModule),
// typeof(AbpElsaActivitiesModule), // typeof(AbpElsaActivitiesModule),
// typeof(AbpElsaEntityFrameworkCoreModule), // typeof(AbpElsaEntityFrameworkCoreModule),
// typeof(AbpElsaEntityFrameworkCorePostgreSqlModule), // typeof(AbpElsaEntityFrameworkCorePostgreSqlModule),
#else // typeof(AbpElsaModule),
typeof(AbpElsaModule), // typeof(AbpElsaServerModule),
typeof(AbpElsaServerModule), // typeof(AbpElsaActivitiesModule),
typeof(AbpElsaActivitiesModule), // typeof(AbpElsaEntityFrameworkCoreModule),
typeof(AbpElsaEntityFrameworkCoreModule), // typeof(AbpElsaEntityFrameworkCoreMySqlModule),
typeof(AbpElsaEntityFrameworkCoreMySqlModule),
#endif
typeof(AbpExporterMiniExcelModule), typeof(AbpExporterMiniExcelModule),
typeof(AbpAspNetCoreMvcUiMultiTenancyModule), typeof(AbpAspNetCoreMvcUiMultiTenancyModule),

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

@ -25,15 +25,6 @@
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
},
"LY.MicroService.Applications.Single.PostgreSQL": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://0.0.0.0:30000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "PostgreSQL"
}
} }
} }
} }

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

@ -36,7 +36,8 @@
} }
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456;SslMode=None" // "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;"//Postgres
}, },
"DistributedLock": { "DistributedLock": {
"IsEnabled": true, "IsEnabled": true,
@ -48,7 +49,7 @@
"Features": { "Features": {
"DefaultPersistence": { "DefaultPersistence": {
"Enabled": true, "Enabled": true,
"ConnectionStringIdentifier": "Workflow", "ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": { "EntityFrameworkCore": {
"MySql": { "MySql": {
"Enabled": true "Enabled": true
@ -71,7 +72,7 @@
"PublishWebhook": true, "PublishWebhook": true,
"Webhooks": { "Webhooks": {
"Enabled": true, "Enabled": true,
"ConnectionStringIdentifier": "Workflow", "ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": { "EntityFrameworkCore": {
"MySql": { "MySql": {
"Enabled": true "Enabled": true
@ -80,7 +81,7 @@
}, },
"WorkflowSettings": { "WorkflowSettings": {
"Enabled": true, "Enabled": true,
"ConnectionStringIdentifier": "Workflow", "ConnectionStringIdentifier": "Default",
"EntityFrameworkCore": { "EntityFrameworkCore": {
"MySql": { "MySql": {
"Enabled": true "Enabled": true
@ -97,10 +98,13 @@
"Properties": { "Properties": {
"quartz.jobStore.dataSource": "tkm", "quartz.jobStore.dataSource": "tkm",
"quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz", "quartz.jobStore.type": "Quartz.Impl.AdoJobStore.JobStoreTX,Quartz",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.MySQLDelegate,Quartz", "quartz.dataSource.tkm.connectionStringName": "Default",
"quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456", // "quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.MySQLDelegate,Quartz",
"quartz.dataSource.tkm.connectionStringName": "TaskManagement", // "quartz.dataSource.tkm.connectionString": "Server=127.0.0.1;Database=Platform-V70;User Id=root;Password=123456",
"quartz.dataSource.tkm.provider": "MySqlConnector", // "quartz.dataSource.tkm.provider": "MySqlConnector",
"quartz.jobStore.driverDelegateType": "Quartz.Impl.AdoJobStore.PostgreSQLDelegate,Quartz",
"quartz.dataSource.tkm.connectionString": "Host=127.0.0.1;Database=Platform-V70;Username=postgres;Password=123456;",
"quartz.dataSource.tkm.provider": "Npgsql",
"quartz.jobStore.clustered": "true", "quartz.jobStore.clustered": "true",
"quartz.serializer.type": "json" "quartz.serializer.type": "json"
} }

2
aspnet-core/tests/LINGYUN.Abp.Aliyun.Tests/LINGYUN.Abp.Aliyun.Tests.csproj

@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RootNamespace /> <RootNamespace />
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<Configurations>Debug;Release;PostgreSQL</Configurations> <Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms> <Platforms>AnyCPU</Platforms>
</PropertyGroup> </PropertyGroup>

2
aspnet-core/tests/LINGYUN.Abp.IP2Region.Tests/LINGYUN.Abp.IP2Region.Tests.csproj

@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RootNamespace /> <RootNamespace />
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<Configurations>Debug;Release;PostgreSQL</Configurations> <Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms> <Platforms>AnyCPU</Platforms>
</PropertyGroup> </PropertyGroup>

2
aspnet-core/tests/LINGYUN.Abp.TestBase/LINGYUN.Abp.TestsBase.csproj

@ -6,7 +6,7 @@
<TargetFramework>net8.0</TargetFramework> <TargetFramework>net8.0</TargetFramework>
<RootNamespace /> <RootNamespace />
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
<Configurations>Debug;Release;PostgreSQL</Configurations> <Configurations>Debug;Release</Configurations>
<Platforms>AnyCPU</Platforms> <Platforms>AnyCPU</Platforms>
</PropertyGroup> </PropertyGroup>

Loading…
Cancel
Save