2025-05-06 06:45:49 +00:00
|
|
|
|
using Kurs.Platform.EntityFrameworkCore;
|
2025-06-10 20:34:46 +00:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2025-05-06 06:45:49 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
|
|
using Volo.Abp.Autofac;
|
|
|
|
|
|
using Volo.Abp.Caching;
|
|
|
|
|
|
using Volo.Abp.Caching.StackExchangeRedis;
|
2025-06-10 20:34:46 +00:00
|
|
|
|
using Volo.Abp.Data;
|
2025-05-06 06:45:49 +00:00
|
|
|
|
using Volo.Abp.Modularity;
|
|
|
|
|
|
using Volo.Abp.VirtualFileSystem;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Kurs.Platform.DbMigrator;
|
|
|
|
|
|
|
|
|
|
|
|
[DependsOn(
|
|
|
|
|
|
typeof(AbpAutofacModule),
|
|
|
|
|
|
typeof(AbpCachingStackExchangeRedisModule),
|
|
|
|
|
|
typeof(PlatformEntityFrameworkCoreModule),
|
|
|
|
|
|
typeof(PlatformApplicationContractsModule)
|
|
|
|
|
|
)]
|
|
|
|
|
|
public class PlatformDbMigratorModule : AbpModule
|
|
|
|
|
|
{
|
|
|
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context)
|
|
|
|
|
|
{
|
|
|
|
|
|
var hostEnvironment = context.Services.GetSingletonInstance<IHostEnvironment>();
|
|
|
|
|
|
|
|
|
|
|
|
ConfigureVirtualFileSystem(context, hostEnvironment);
|
|
|
|
|
|
Configure<AbpDistributedCacheOptions>(options => { options.KeyPrefix = "Platform:"; });
|
2025-06-10 20:34:46 +00:00
|
|
|
|
|
|
|
|
|
|
var configuration = context.Services.GetConfiguration();
|
|
|
|
|
|
var connectionString = configuration.GetConnectionString(PlatformConsts.DefaultDatabaseProvider);
|
|
|
|
|
|
|
|
|
|
|
|
Configure<AbpDbConnectionOptions>(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.ConnectionStrings.Default = connectionString;
|
|
|
|
|
|
});
|
2025-05-06 06:45:49 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ConfigureVirtualFileSystem(ServiceConfigurationContext context, IHostEnvironment hostEnvironment)
|
|
|
|
|
|
{
|
|
|
|
|
|
Configure<AbpVirtualFileSystemOptions>(options =>
|
|
|
|
|
|
{
|
|
|
|
|
|
options.FileSets.AddEmbedded<PlatformDbMigratorModule>();
|
|
|
|
|
|
// if (hostEnvironment.IsDevelopment())
|
|
|
|
|
|
// {
|
|
|
|
|
|
// options.FileSets.ReplaceEmbeddedByPhysical<PlatformDbMigratorModule>(
|
|
|
|
|
|
// Path.Combine(hostEnvironment.ContentRootPath,
|
|
|
|
|
|
// // $"..{Path.DirectorySeparatorChar}Kurs.Platform.DbMigrator"));
|
|
|
|
|
|
// $"..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}"));
|
|
|
|
|
|
// }
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|