committed by
GitHub
625 changed files with 27525 additions and 5299 deletions
@ -0,0 +1,51 @@ |
|||||
|
using LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Serilog; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
|
||||
|
namespace LY.MicroService.AuthServer.DbMigrator; |
||||
|
|
||||
|
public class AuthServerDbMigratorHostedService : IHostedService |
||||
|
{ |
||||
|
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public AuthServerDbMigratorHostedService( |
||||
|
IHostApplicationLifetime hostApplicationLifetime, |
||||
|
IConfiguration configuration) |
||||
|
{ |
||||
|
_hostApplicationLifetime = hostApplicationLifetime; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public async Task StartAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
using var application = await AbpApplicationFactory |
||||
|
.CreateAsync<AuthServerDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(_configuration); |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
options.AddDataMigrationEnvironment(); |
||||
|
}); |
||||
|
await application.InitializeAsync(); |
||||
|
|
||||
|
await application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<AuthServerDbMigrationService>() |
||||
|
.MigrateAsync(); |
||||
|
|
||||
|
await application.ShutdownAsync(); |
||||
|
|
||||
|
_hostApplicationLifetime.StopApplication(); |
||||
|
} |
||||
|
|
||||
|
public Task StopAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,18 @@ |
|||||
|
using LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.AuthServer.DbMigrator; |
||||
|
public partial class AuthServerDbMigratorModule |
||||
|
{ |
||||
|
private void ConfigureDbContext(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpDbContext<AuthServerMigrationsDbContext>(); |
||||
|
|
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Identity.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.OpenIddict.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.AuthServer.DbMigrator; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpSaasEntityFrameworkCoreModule), |
||||
|
typeof(AbpIdentityEntityFrameworkCoreModule), |
||||
|
typeof(AbpOpenIddictEntityFrameworkCoreModule), |
||||
|
typeof(AbpDataDbMigratorModule), |
||||
|
typeof(AbpAutofacModule) |
||||
|
)] |
||||
|
public partial class AuthServerDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
ConfigureDbContext(context.Services); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.Tenants; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class AuthServerDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<AuthServerDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public AuthServerDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IDbSchemaMigrator dbSchemaMigrator, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<AuthServerDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
// 迁移租户数据
|
||||
|
await _dbSchemaMigrator.MigrateAsync<AuthServerMigrationsDbContext>( |
||||
|
(connectionString, builder) => |
||||
|
{ |
||||
|
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new AuthServerMigrationsDbContext(builder.Options); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(tenant?.Id); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
return Path.Combine(slnDirectoryPath, "LY.MicroService.BackendAdmin.DbMigrator"); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
|
||||
|
// parent host
|
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Identity.EntityFrameworkCore; |
||||
|
using Volo.Abp.OpenIddict.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.AuthServer.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
[ConnectionStringName("AuthServerDbMigrator")] |
||||
|
public class AuthServerMigrationsDbContext : AbpDbContext<AuthServerMigrationsDbContext> |
||||
|
{ |
||||
|
public AuthServerMigrationsDbContext(DbContextOptions<AuthServerMigrationsDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigureIdentity(); |
||||
|
modelBuilder.ConfigureOpenIddict(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Folder Include="Migrations\" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
File diff suppressed because it is too large
@ -0,0 +1,738 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.AuthServer.DbMigrator.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class InitialAuthServer : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AlterDatabase() |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpClaimTypes", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Required = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
IsStatic = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
Regex = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
RegexDescription = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ValueType = table.Column<int>(type: "int", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpClaimTypes", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpLinkUsers", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
SourceUserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
SourceTenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
TargetUserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TargetTenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpLinkUsers", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpOrganizationUnits", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Code = table.Column<string>(type: "varchar(95)", maxLength: 95, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpOrganizationUnits", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpOrganizationUnits_AbpOrganizationUnits_ParentId", |
||||
|
column: x => x.ParentId, |
||||
|
principalTable: "AbpOrganizationUnits", |
||||
|
principalColumn: "Id"); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpRoles", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
NormalizedName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
IsDefault = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
IsStatic = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
IsPublic = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpRoles", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpSecurityLogs", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
ApplicationName = table.Column<string>(type: "varchar(96)", maxLength: 96, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Identity = table.Column<string>(type: "varchar(96)", maxLength: 96, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Action = table.Column<string>(type: "varchar(96)", maxLength: 96, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
TenantName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ClientId = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CorrelationId = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ClientIpAddress = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
BrowserInfo = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpSecurityLogs", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpUsers", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
NormalizedUserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Surname = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Email = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
NormalizedEmail = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
EmailConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
PasswordHash = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
SecurityStamp = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
IsExternal = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
PhoneNumber = table.Column<string>(type: "varchar(16)", maxLength: 16, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
PhoneNumberConfirmed = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
TwoFactorEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
LockoutEnd = table.Column<DateTimeOffset>(type: "datetime(6)", nullable: true), |
||||
|
LockoutEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
AccessFailedCount = table.Column<int>(type: "int", nullable: false, defaultValue: 0), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpUsers", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "OpenIddictApplications", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
ClientId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ClientSecret = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConsentType = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayNames = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Permissions = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
PostLogoutRedirectUris = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Properties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
RedirectUris = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Requirements = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Type = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ClientUri = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
LogoUri = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_OpenIddictApplications", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "OpenIddictScopes", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Description = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Descriptions = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayNames = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Properties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Resources = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_OpenIddictScopes", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpOrganizationUnitRoles", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
OrganizationUnitId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpOrganizationUnitRoles", x => new { x.OrganizationUnitId, x.RoleId }); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpOrganizationUnitRoles_AbpOrganizationUnits_OrganizationUn~", |
||||
|
column: x => x.OrganizationUnitId, |
||||
|
principalTable: "AbpOrganizationUnits", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpOrganizationUnitRoles_AbpRoles_RoleId", |
||||
|
column: x => x.RoleId, |
||||
|
principalTable: "AbpRoles", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpRoleClaims", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
ClaimType = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ClaimValue = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpRoleClaims", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpRoleClaims_AbpRoles_RoleId", |
||||
|
column: x => x.RoleId, |
||||
|
principalTable: "AbpRoles", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpUserClaims", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
ClaimType = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ClaimValue = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpUserClaims", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpUserClaims_AbpUsers_UserId", |
||||
|
column: x => x.UserId, |
||||
|
principalTable: "AbpUsers", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpUserLogins", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
LoginProvider = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
ProviderKey = table.Column<string>(type: "varchar(196)", maxLength: 196, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ProviderDisplayName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpUserLogins", x => new { x.UserId, x.LoginProvider }); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpUserLogins_AbpUsers_UserId", |
||||
|
column: x => x.UserId, |
||||
|
principalTable: "AbpUsers", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpUserOrganizationUnits", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
OrganizationUnitId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpUserOrganizationUnits", x => new { x.OrganizationUnitId, x.UserId }); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpUserOrganizationUnits_AbpOrganizationUnits_OrganizationUn~", |
||||
|
column: x => x.OrganizationUnitId, |
||||
|
principalTable: "AbpOrganizationUnits", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpUserOrganizationUnits_AbpUsers_UserId", |
||||
|
column: x => x.UserId, |
||||
|
principalTable: "AbpUsers", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpUserRoles", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
RoleId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpUserRoles", x => new { x.UserId, x.RoleId }); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpUserRoles_AbpRoles_RoleId", |
||||
|
column: x => x.RoleId, |
||||
|
principalTable: "AbpRoles", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpUserRoles_AbpUsers_UserId", |
||||
|
column: x => x.UserId, |
||||
|
principalTable: "AbpUsers", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpUserTokens", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
LoginProvider = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Value = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpUserTokens", x => new { x.UserId, x.LoginProvider, x.Name }); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpUserTokens_AbpUsers_UserId", |
||||
|
column: x => x.UserId, |
||||
|
principalTable: "AbpUsers", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "OpenIddictAuthorizations", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
ApplicationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
Properties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Scopes = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Status = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Subject = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Type = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_OpenIddictAuthorizations", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_OpenIddictAuthorizations_OpenIddictApplications_ApplicationId", |
||||
|
column: x => x.ApplicationId, |
||||
|
principalTable: "OpenIddictApplications", |
||||
|
principalColumn: "Id"); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "OpenIddictTokens", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
ApplicationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
AuthorizationId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
CreationDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
ExpirationDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
Payload = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Properties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
RedemptionDate = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
ReferenceId = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Status = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Subject = table.Column<string>(type: "varchar(400)", maxLength: 400, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Type = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_OpenIddictTokens", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_OpenIddictTokens_OpenIddictApplications_ApplicationId", |
||||
|
column: x => x.ApplicationId, |
||||
|
principalTable: "OpenIddictApplications", |
||||
|
principalColumn: "Id"); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_OpenIddictTokens_OpenIddictAuthorizations_AuthorizationId", |
||||
|
column: x => x.AuthorizationId, |
||||
|
principalTable: "OpenIddictAuthorizations", |
||||
|
principalColumn: "Id"); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpLinkUsers_SourceUserId_SourceTenantId_TargetUserId_Target~", |
||||
|
table: "AbpLinkUsers", |
||||
|
columns: new[] { "SourceUserId", "SourceTenantId", "TargetUserId", "TargetTenantId" }, |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpOrganizationUnitRoles_RoleId_OrganizationUnitId", |
||||
|
table: "AbpOrganizationUnitRoles", |
||||
|
columns: new[] { "RoleId", "OrganizationUnitId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpOrganizationUnits_Code", |
||||
|
table: "AbpOrganizationUnits", |
||||
|
column: "Code"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpOrganizationUnits_ParentId", |
||||
|
table: "AbpOrganizationUnits", |
||||
|
column: "ParentId"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpRoleClaims_RoleId", |
||||
|
table: "AbpRoleClaims", |
||||
|
column: "RoleId"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpRoles_NormalizedName", |
||||
|
table: "AbpRoles", |
||||
|
column: "NormalizedName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpSecurityLogs_TenantId_Action", |
||||
|
table: "AbpSecurityLogs", |
||||
|
columns: new[] { "TenantId", "Action" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpSecurityLogs_TenantId_ApplicationName", |
||||
|
table: "AbpSecurityLogs", |
||||
|
columns: new[] { "TenantId", "ApplicationName" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpSecurityLogs_TenantId_Identity", |
||||
|
table: "AbpSecurityLogs", |
||||
|
columns: new[] { "TenantId", "Identity" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpSecurityLogs_TenantId_UserId", |
||||
|
table: "AbpSecurityLogs", |
||||
|
columns: new[] { "TenantId", "UserId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUserClaims_UserId", |
||||
|
table: "AbpUserClaims", |
||||
|
column: "UserId"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUserLogins_LoginProvider_ProviderKey", |
||||
|
table: "AbpUserLogins", |
||||
|
columns: new[] { "LoginProvider", "ProviderKey" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUserOrganizationUnits_UserId_OrganizationUnitId", |
||||
|
table: "AbpUserOrganizationUnits", |
||||
|
columns: new[] { "UserId", "OrganizationUnitId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUserRoles_RoleId_UserId", |
||||
|
table: "AbpUserRoles", |
||||
|
columns: new[] { "RoleId", "UserId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUsers_Email", |
||||
|
table: "AbpUsers", |
||||
|
column: "Email"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUsers_NormalizedEmail", |
||||
|
table: "AbpUsers", |
||||
|
column: "NormalizedEmail"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUsers_NormalizedUserName", |
||||
|
table: "AbpUsers", |
||||
|
column: "NormalizedUserName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpUsers_UserName", |
||||
|
table: "AbpUsers", |
||||
|
column: "UserName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_OpenIddictApplications_ClientId", |
||||
|
table: "OpenIddictApplications", |
||||
|
column: "ClientId"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_OpenIddictAuthorizations_ApplicationId_Status_Subject_Type", |
||||
|
table: "OpenIddictAuthorizations", |
||||
|
columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_OpenIddictScopes_Name", |
||||
|
table: "OpenIddictScopes", |
||||
|
column: "Name"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_OpenIddictTokens_ApplicationId_Status_Subject_Type", |
||||
|
table: "OpenIddictTokens", |
||||
|
columns: new[] { "ApplicationId", "Status", "Subject", "Type" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_OpenIddictTokens_AuthorizationId", |
||||
|
table: "OpenIddictTokens", |
||||
|
column: "AuthorizationId"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_OpenIddictTokens_ReferenceId", |
||||
|
table: "OpenIddictTokens", |
||||
|
column: "ReferenceId"); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpClaimTypes"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpLinkUsers"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpOrganizationUnitRoles"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpRoleClaims"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpSecurityLogs"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpUserClaims"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpUserLogins"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpUserOrganizationUnits"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpUserRoles"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpUserTokens"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "OpenIddictScopes"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "OpenIddictTokens"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpOrganizationUnits"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpRoles"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpUsers"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "OpenIddictAuthorizations"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "OpenIddictApplications"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
File diff suppressed because it is too large
@ -0,0 +1,40 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
|
||||
|
namespace LY.MicroService.AuthServer.DbMigrator; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public async static Task Main(string[] args) |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("LY.MicroService.AuthServer.DbMigrator", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("LY.MicroService.AuthServer.DbMigrator", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.Console() |
||||
|
.WriteTo.File("Logs/migrations.txt") |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
await CreateHostBuilder(args).RunConsoleAsync(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) |
||||
|
{ |
||||
|
return Host.CreateDefaultBuilder(args) |
||||
|
.AddAppSettingsSecretsJson() |
||||
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
||||
|
.ConfigureServices((hostContext, services) => |
||||
|
{ |
||||
|
services.AddHostedService<AuthServerDbMigratorHostedService>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"profiles": { |
||||
|
"LY.MicroService.AuthServer.DbMigrator": { |
||||
|
"commandName": "Project", |
||||
|
"dotnetRunMessages": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using LINGYUN.Abp; |
||||
@ -0,0 +1,78 @@ |
|||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456", |
||||
|
"AbpIdentity": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456", |
||||
|
"OpenIddict": "Server=127.0.0.1;Database=AuthServer-v70;User Id=root;Password=123456", |
||||
|
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"StringEncryption": { |
||||
|
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
|
"InitVectorBytes": "s83ng0abvd02js84", |
||||
|
"DefaultSalt": "sf&5)s3#" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Information", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Debug-.log", |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Info-.log", |
||||
|
"restrictedToMinimumLevel": "Information", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Warn-.log", |
||||
|
"restrictedToMinimumLevel": "Warning", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Error-.log", |
||||
|
"restrictedToMinimumLevel": "Error", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Fatal-.log", |
||||
|
"restrictedToMinimumLevel": "Fatal", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Serilog; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator; |
||||
|
|
||||
|
public class BackendAdminDbMigratorHostedService : IHostedService |
||||
|
{ |
||||
|
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public BackendAdminDbMigratorHostedService( |
||||
|
IHostApplicationLifetime hostApplicationLifetime, |
||||
|
IConfiguration configuration) |
||||
|
{ |
||||
|
_hostApplicationLifetime = hostApplicationLifetime; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public async Task StartAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
using var application = await AbpApplicationFactory |
||||
|
.CreateAsync<BackendAdminDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(_configuration); |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
options.AddDataMigrationEnvironment(); |
||||
|
}); |
||||
|
await application.InitializeAsync(); |
||||
|
|
||||
|
await application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<BackendAdminDbMigrationService>() |
||||
|
.MigrateAsync(); |
||||
|
|
||||
|
await application.ShutdownAsync(); |
||||
|
|
||||
|
_hostApplicationLifetime.StopApplication(); |
||||
|
} |
||||
|
|
||||
|
public Task StopAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,18 @@ |
|||||
|
using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator; |
||||
|
public partial class BackendAdminDbMigratorModule |
||||
|
{ |
||||
|
private void ConfigureDbContext(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpDbContext<BackendAdminMigrationsDbContext>(); |
||||
|
|
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpSaasEntityFrameworkCoreModule), |
||||
|
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpTextTemplatingEntityFrameworkCoreModule), |
||||
|
typeof(AbpDataDbMigratorModule), |
||||
|
typeof(AbpAutofacModule) |
||||
|
)] |
||||
|
public partial class BackendAdminDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
ConfigureDbContext(context.Services); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.Tenants; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class BackendAdminDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<BackendAdminDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public BackendAdminDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IDbSchemaMigrator dbSchemaMigrator, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<BackendAdminDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
// 迁移租户数据
|
||||
|
await _dbSchemaMigrator.MigrateAsync<BackendAdminMigrationsDbContext>( |
||||
|
(connectionString, builder) => |
||||
|
{ |
||||
|
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new BackendAdminMigrationsDbContext(builder.Options); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(tenant?.Id); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
return Path.Combine(slnDirectoryPath, "LY.MicroService.BackendAdmin.DbMigrator"); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
|
||||
|
// parent host
|
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.TextTemplating.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
[ConnectionStringName("BackendAdminDbMigrator")] |
||||
|
public class BackendAdminMigrationsDbContext : AbpDbContext<BackendAdminMigrationsDbContext> |
||||
|
{ |
||||
|
public BackendAdminMigrationsDbContext(DbContextOptions<BackendAdminMigrationsDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigureSaas(); |
||||
|
modelBuilder.ConfigureTextTemplating(); |
||||
|
modelBuilder.ConfigureFeatureManagement(); |
||||
|
modelBuilder.ConfigureSettingManagement(); |
||||
|
modelBuilder.ConfigurePermissionManagement(); |
||||
|
} |
||||
|
} |
||||
@ -1,30 +1,29 @@ |
|||||
using System.IO; |
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore.Design; |
||||
using Microsoft.EntityFrameworkCore.Design; |
using Microsoft.Extensions.Configuration; |
||||
using Microsoft.Extensions.Configuration; |
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; |
||||
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore; |
|
||||
|
|
||||
public class BackendAdminMigrationsDbContextFactory : IDesignTimeDbContextFactory<BackendAdminMigrationsDbContext> |
public class BackendAdminMigrationsDbContextFactory : IDesignTimeDbContextFactory<BackendAdminMigrationsDbContext> |
||||
{ |
{ |
||||
public BackendAdminMigrationsDbContext CreateDbContext(string[] args) |
public BackendAdminMigrationsDbContext CreateDbContext(string[] args) |
||||
{ |
{ |
||||
var configuration = BuildConfiguration(); |
var configuration = BuildConfiguration(); |
||||
|
|
||||
var connectionString = configuration.GetConnectionString("Default"); |
var connectionString = configuration.GetConnectionString("Default"); |
||||
|
|
||||
var builder = new DbContextOptionsBuilder<BackendAdminMigrationsDbContext>() |
var builder = new DbContextOptionsBuilder<BackendAdminMigrationsDbContext>() |
||||
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
return new BackendAdminMigrationsDbContext(builder.Options); |
return new BackendAdminMigrationsDbContext(builder!.Options); |
||||
} |
} |
||||
|
|
||||
private static IConfigurationRoot BuildConfiguration() |
private static IConfigurationRoot BuildConfiguration() |
||||
{ |
{ |
||||
var builder = new ConfigurationBuilder() |
var builder = new ConfigurationBuilder() |
||||
.SetBasePath(Directory.GetCurrentDirectory()) |
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
.AddJsonFile("appsettings.Development.json", optional: false); |
.AddJsonFile("appsettings.json", optional: false) |
||||
|
.AddJsonFile("appsettings.Development.json", optional: true); |
||||
|
|
||||
return builder.Build(); |
return builder.Build(); |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\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\text-templating\LINGYUN.Abp.TextTemplating.EntityFrameworkCore\LINGYUN.Abp.TextTemplating.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,524 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(BackendAdminMigrationsDbContext))] |
||||
|
[Migration("20230109083613_Initial-Backend-Admin")] |
||||
|
partial class InitialBackendAdmin |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("DisplayName"); |
||||
|
|
||||
|
b.ToTable("AbpEditions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<DateTime?>("DisableTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<Guid?>("EditionId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime?>("EnableTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsActive") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("EditionId"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AbpTenants", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
||||
|
{ |
||||
|
b.Property<Guid>("TenantId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)"); |
||||
|
|
||||
|
b.HasKey("TenantId", "Name"); |
||||
|
|
||||
|
b.ToTable("AbpTenantConnectionStrings", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("Content"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Culture") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Culture"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "Name") |
||||
|
.HasDatabaseName("IX_Tenant_Text_Template_Name"); |
||||
|
|
||||
|
b.ToTable("AbpTextTemplates", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("AllowedProviders") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("DefaultValue") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<bool>("IsAvailableToHost") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsVisibleToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ParentName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ValueType") |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("GroupName"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatures", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatureGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "ProviderName", "ProviderKey") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatureValues", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<byte>("MultiTenancySide") |
||||
|
.HasColumnType("tinyint unsigned"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ParentName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("Providers") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("StateCheckers") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("GroupName"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissionGrants", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissionGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "ProviderName", "ProviderKey") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpSettings", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("EditionId"); |
||||
|
|
||||
|
b.Navigation("Edition"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) |
||||
|
.WithMany("ConnectionStrings") |
||||
|
.HasForeignKey("TenantId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
||||
|
{ |
||||
|
b.Navigation("ConnectionStrings"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,388 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class InitialBackendAdmin : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AlterDatabase() |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpEditions", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpEditions", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpFeatureGroups", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpFeatureGroups", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpFeatures", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
GroupName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ParentName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DefaultValue = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
IsVisibleToClients = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
IsAvailableToHost = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
AllowedProviders = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ValueType = table.Column<string>(type: "varchar(2048)", maxLength: 2048, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpFeatures", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpFeatureValues", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Value = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ProviderName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ProviderKey = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpFeatureValues", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpPermissionGrants", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ProviderName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ProviderKey = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpPermissionGrants", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpPermissionGroups", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpPermissionGroups", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpPermissions", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
GroupName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ParentName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
IsEnabled = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
MultiTenancySide = table.Column<byte>(type: "tinyint unsigned", nullable: false), |
||||
|
Providers = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
StateCheckers = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpPermissions", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpSettings", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Value = table.Column<string>(type: "varchar(2048)", maxLength: 2048, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ProviderName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ProviderKey = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpSettings", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpTextTemplates", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Content = table.Column<string>(type: "longtext", maxLength: 1048576, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Culture = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpTextTemplates", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpTenants", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
EnableTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
DisableTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
EditionId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpTenants", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpTenants_AbpEditions_EditionId", |
||||
|
column: x => x.EditionId, |
||||
|
principalTable: "AbpEditions", |
||||
|
principalColumn: "Id"); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpTenantConnectionStrings", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Value = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpTenantConnectionStrings", x => new { x.TenantId, x.Name }); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AbpTenantConnectionStrings_AbpTenants_TenantId", |
||||
|
column: x => x.TenantId, |
||||
|
principalTable: "AbpTenants", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpEditions_DisplayName", |
||||
|
table: "AbpEditions", |
||||
|
column: "DisplayName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpFeatureGroups_Name", |
||||
|
table: "AbpFeatureGroups", |
||||
|
column: "Name", |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpFeatures_GroupName", |
||||
|
table: "AbpFeatures", |
||||
|
column: "GroupName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpFeatures_Name", |
||||
|
table: "AbpFeatures", |
||||
|
column: "Name", |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpFeatureValues_Name_ProviderName_ProviderKey", |
||||
|
table: "AbpFeatureValues", |
||||
|
columns: new[] { "Name", "ProviderName", "ProviderKey" }, |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpPermissionGrants_TenantId_Name_ProviderName_ProviderKey", |
||||
|
table: "AbpPermissionGrants", |
||||
|
columns: new[] { "TenantId", "Name", "ProviderName", "ProviderKey" }, |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpPermissionGroups_Name", |
||||
|
table: "AbpPermissionGroups", |
||||
|
column: "Name", |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpPermissions_GroupName", |
||||
|
table: "AbpPermissions", |
||||
|
column: "GroupName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpPermissions_Name", |
||||
|
table: "AbpPermissions", |
||||
|
column: "Name", |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpSettings_Name_ProviderName_ProviderKey", |
||||
|
table: "AbpSettings", |
||||
|
columns: new[] { "Name", "ProviderName", "ProviderKey" }, |
||||
|
unique: true); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpTenants_EditionId", |
||||
|
table: "AbpTenants", |
||||
|
column: "EditionId"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpTenants_Name", |
||||
|
table: "AbpTenants", |
||||
|
column: "Name"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_Tenant_Text_Template_Name", |
||||
|
table: "AbpTextTemplates", |
||||
|
columns: new[] { "TenantId", "Name" }); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpFeatureGroups"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpFeatures"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpFeatureValues"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpPermissionGrants"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpPermissionGroups"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpPermissions"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpSettings"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpTenantConnectionStrings"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpTextTemplates"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpTenants"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpEditions"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,521 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.BackendAdmin.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(BackendAdminMigrationsDbContext))] |
||||
|
partial class BackendAdminMigrationsDbContextModelSnapshot : ModelSnapshot |
||||
|
{ |
||||
|
protected override void BuildModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Editions.Edition", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("DisplayName"); |
||||
|
|
||||
|
b.ToTable("AbpEditions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<DateTime?>("DisableTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<Guid?>("EditionId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime?>("EnableTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsActive") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("EditionId"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AbpTenants", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
||||
|
{ |
||||
|
b.Property<Guid>("TenantId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)"); |
||||
|
|
||||
|
b.HasKey("TenantId", "Name"); |
||||
|
|
||||
|
b.ToTable("AbpTenantConnectionStrings", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.TextTemplating.TextTemplate", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("Content"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Culture") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Culture"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "Name") |
||||
|
.HasDatabaseName("IX_Tenant_Text_Template_Name"); |
||||
|
|
||||
|
b.ToTable("AbpTextTemplates", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("AllowedProviders") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("DefaultValue") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<bool>("IsAvailableToHost") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsVisibleToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ParentName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ValueType") |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("GroupName"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatures", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureGroupDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatureGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.FeatureManagement.FeatureValue", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "ProviderName", "ProviderKey") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpFeatureValues", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<bool>("IsEnabled") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<byte>("MultiTenancySide") |
||||
|
.HasColumnType("tinyint unsigned"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ParentName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("Providers") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("StateCheckers") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("GroupName"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGrant", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "Name", "ProviderName", "ProviderKey") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissionGrants", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.PermissionManagement.PermissionGroupDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpPermissionGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("Volo.Abp.SettingManagement.Setting", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<string>("ProviderKey") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("ProviderName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "ProviderName", "ProviderKey") |
||||
|
.IsUnique(); |
||||
|
|
||||
|
b.ToTable("AbpSettings", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Abp.Saas.Editions.Edition", "Edition") |
||||
|
.WithMany() |
||||
|
.HasForeignKey("EditionId"); |
||||
|
|
||||
|
b.Navigation("Edition"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.TenantConnectionString", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Abp.Saas.Tenants.Tenant", null) |
||||
|
.WithMany("ConnectionStrings") |
||||
|
.HasForeignKey("TenantId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Saas.Tenants.Tenant", b => |
||||
|
{ |
||||
|
b.Navigation("ConnectionStrings"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
|
||||
|
namespace LY.MicroService.BackendAdmin.DbMigrator; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public async static Task Main(string[] args) |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("LY.MicroService.BackendAdmin.DbMigrator", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("LY.MicroService.BackendAdmin.DbMigrator", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.Console() |
||||
|
.WriteTo.File("Logs/migrations.txt") |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
await CreateHostBuilder(args).RunConsoleAsync(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) |
||||
|
{ |
||||
|
return Host.CreateDefaultBuilder(args) |
||||
|
.AddAppSettingsSecretsJson() |
||||
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
||||
|
.ConfigureServices((hostContext, services) => |
||||
|
{ |
||||
|
services.AddHostedService<BackendAdminDbMigratorHostedService>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"profiles": { |
||||
|
"LY.MicroService.BackendAdmin.DbMigrator": { |
||||
|
"commandName": "Project", |
||||
|
"dotnetRunMessages": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using LINGYUN.Abp; |
||||
@ -0,0 +1,80 @@ |
|||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpFeatureManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpTextTemplating": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"StringEncryption": { |
||||
|
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
|
"InitVectorBytes": "s83ng0abvd02js84", |
||||
|
"DefaultSalt": "sf&5)s3#" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Information", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Debug-.log", |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Info-.log", |
||||
|
"restrictedToMinimumLevel": "Information", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Warn-.log", |
||||
|
"restrictedToMinimumLevel": "Warning", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Error-.log", |
||||
|
"restrictedToMinimumLevel": "Error", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Fatal-.log", |
||||
|
"restrictedToMinimumLevel": "Fatal", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,6 @@ |
|||||
|
namespace LY.MicroService.IdentityServer.DbMigrator.DataSeeder; |
||||
|
|
||||
|
public interface IWeChatResourceDataSeeder |
||||
|
{ |
||||
|
Task CreateStandardResourcesAsync(); |
||||
|
} |
||||
@ -0,0 +1,299 @@ |
|||||
|
using LINGYUN.Abp.IdentityServer.IdentityResources; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.IO; |
||||
|
using System.Linq; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.IdentityServer.ApiResources; |
||||
|
using Volo.Abp.IdentityServer.ApiScopes; |
||||
|
using Volo.Abp.IdentityServer.Clients; |
||||
|
using Volo.Abp.IdentityServer.IdentityResources; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.Uow; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator.DataSeeder; |
||||
|
|
||||
|
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency |
||||
|
{ |
||||
|
private readonly IApiResourceRepository _apiResourceRepository; |
||||
|
private readonly IApiScopeRepository _apiScopeRepository; |
||||
|
private readonly IClientRepository _clientRepository; |
||||
|
private readonly ICustomIdentityResourceDataSeeder _customIdentityResourceDataSeeder; |
||||
|
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; |
||||
|
private readonly IWeChatResourceDataSeeder _weChatResourceDataSeeder; |
||||
|
private readonly IGuidGenerator _guidGenerator; |
||||
|
private readonly IPermissionDataSeeder _permissionDataSeeder; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public IdentityServerDataSeedContributor( |
||||
|
IClientRepository clientRepository, |
||||
|
IApiScopeRepository apiScopeRepository, |
||||
|
IPermissionDataSeeder permissionDataSeeder, |
||||
|
IApiResourceRepository apiResourceRepository, |
||||
|
IWeChatResourceDataSeeder weChatResourceDataSeeder, |
||||
|
IIdentityResourceDataSeeder identityResourceDataSeeder, |
||||
|
ICustomIdentityResourceDataSeeder customIdentityResourceDataSeeder, |
||||
|
IGuidGenerator guidGenerator, |
||||
|
ICurrentTenant currentTenant, |
||||
|
IConfiguration configuration) |
||||
|
{ |
||||
|
_currentTenant = currentTenant; |
||||
|
_clientRepository = clientRepository; |
||||
|
_permissionDataSeeder = permissionDataSeeder; |
||||
|
_apiScopeRepository = apiScopeRepository; |
||||
|
_apiResourceRepository = apiResourceRepository; |
||||
|
_weChatResourceDataSeeder = weChatResourceDataSeeder; |
||||
|
_identityResourceDataSeeder = identityResourceDataSeeder; |
||||
|
_customIdentityResourceDataSeeder = customIdentityResourceDataSeeder; |
||||
|
_guidGenerator = guidGenerator; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public async virtual Task SeedAsync(DataSeedContext context) |
||||
|
{ |
||||
|
using (_currentTenant.Change(context?.TenantId)) |
||||
|
{ |
||||
|
await _identityResourceDataSeeder.CreateStandardResourcesAsync(); |
||||
|
await _customIdentityResourceDataSeeder.CreateCustomResourcesAsync(); |
||||
|
await CreateWeChatClaimTypeAsync(); |
||||
|
await CreateApiResourcesAsync(); |
||||
|
await CreateApiScopesAsync(); |
||||
|
await CreateClientsAsync(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task CreateWeChatClaimTypeAsync() |
||||
|
{ |
||||
|
await _weChatResourceDataSeeder.CreateStandardResourcesAsync(); |
||||
|
} |
||||
|
|
||||
|
private async Task CreateApiScopesAsync() |
||||
|
{ |
||||
|
await CreateApiScopeAsync("lingyun-abp-application"); |
||||
|
} |
||||
|
|
||||
|
private async Task CreateApiResourcesAsync() |
||||
|
{ |
||||
|
var commonApiUserClaims = new[] |
||||
|
{ |
||||
|
"email", |
||||
|
"email_verified", |
||||
|
"name", |
||||
|
"phone_number", |
||||
|
"phone_number_verified", |
||||
|
"role" |
||||
|
}; |
||||
|
|
||||
|
await CreateApiResourceAsync("lingyun-abp-application", commonApiUserClaims); |
||||
|
} |
||||
|
|
||||
|
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims, IEnumerable<string> secrets = null) |
||||
|
{ |
||||
|
var apiResource = await _apiResourceRepository.FindByNameAsync(name); |
||||
|
if (apiResource == null) |
||||
|
{ |
||||
|
apiResource = await _apiResourceRepository.InsertAsync( |
||||
|
new ApiResource( |
||||
|
_guidGenerator.Create(), |
||||
|
name, |
||||
|
name + " API" |
||||
|
), |
||||
|
autoSave: true |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
foreach (var claim in claims) |
||||
|
{ |
||||
|
if (apiResource.FindClaim(claim) == null) |
||||
|
{ |
||||
|
apiResource.AddUserClaim(claim); |
||||
|
} |
||||
|
} |
||||
|
if (secrets != null) |
||||
|
{ |
||||
|
foreach (var secret in secrets) |
||||
|
{ |
||||
|
if (apiResource.FindSecret(secret) == null) |
||||
|
{ |
||||
|
apiResource.AddSecret(secret); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return await _apiResourceRepository.UpdateAsync(apiResource); |
||||
|
} |
||||
|
|
||||
|
private async Task<ApiScope> CreateApiScopeAsync(string name) |
||||
|
{ |
||||
|
var apiScope = await _apiScopeRepository.FindByNameAsync(name); |
||||
|
if (apiScope == null) |
||||
|
{ |
||||
|
apiScope = await _apiScopeRepository.InsertAsync( |
||||
|
new ApiScope( |
||||
|
_guidGenerator.Create(), |
||||
|
name, |
||||
|
name + " API" |
||||
|
), |
||||
|
autoSave: true |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
return apiScope; |
||||
|
} |
||||
|
|
||||
|
private async Task CreateClientsAsync() |
||||
|
{ |
||||
|
|
||||
|
string commonSecret = IdentityServer4.Models.HashExtensions.Sha256("1q2w3e*"); |
||||
|
|
||||
|
var commonScopes = new[] |
||||
|
{ |
||||
|
"email", |
||||
|
"openid", |
||||
|
"profile", |
||||
|
"role", |
||||
|
"phone", |
||||
|
"address", |
||||
|
"offline_access" // 加上刷新,
|
||||
|
|
||||
|
}; |
||||
|
|
||||
|
var configurationSection = _configuration.GetSection("IdentityServer:Clients"); |
||||
|
|
||||
|
var vueClientId = configurationSection["AuthVueAdmin:ClientId"]; |
||||
|
if (!vueClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var vueClientPermissions = new string[1] |
||||
|
{ |
||||
|
"AbpIdentity.UserLookup" |
||||
|
}; |
||||
|
var vueClientRootUrl = configurationSection["AuthVueAdmin:RootUrl"].EnsureEndsWith('/'); |
||||
|
await CreateClientAsync( |
||||
|
vueClientId, |
||||
|
commonScopes.Union(new[] { "lingyun-abp-application" }), |
||||
|
new[] { "password", "client_credentials", "implicit", "phone_verify", "wx-mp" }, |
||||
|
commonSecret, |
||||
|
redirectUri: $"{vueClientRootUrl}signin-oidc", |
||||
|
postLogoutRedirectUri: $"{vueClientRootUrl}signout-callback-oidc", |
||||
|
corsOrigins: configurationSection["CorsOrigins"], |
||||
|
permissions: vueClientPermissions |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
// InternalService 内部服务间通讯客户端,必要的话需要在前端指定它拥有所有权限,当前项目仅预置用户查询权限
|
||||
|
var internalServiceClientId = configurationSection["InternalService:ClientId"]; |
||||
|
if (!internalServiceClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var internalServicePermissions = new string[2] |
||||
|
{ |
||||
|
"AbpIdentity.UserLookup","AbpIdentity.Users" |
||||
|
}; |
||||
|
await CreateClientAsync( |
||||
|
internalServiceClientId, |
||||
|
commonScopes.Union(new[] { "lingyun-abp-application" }), |
||||
|
new[] { "client_credentials" }, |
||||
|
commonSecret, |
||||
|
permissions: internalServicePermissions |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task<Client> CreateClientAsync( |
||||
|
string name, |
||||
|
IEnumerable<string> scopes, |
||||
|
IEnumerable<string> grantTypes, |
||||
|
string secret, |
||||
|
string redirectUri = null, |
||||
|
string postLogoutRedirectUri = null, |
||||
|
IEnumerable<string> permissions = null, |
||||
|
string corsOrigins = null) |
||||
|
{ |
||||
|
var client = await _clientRepository.FindByClientIdAsync(name); |
||||
|
if (client == null) |
||||
|
{ |
||||
|
client = await _clientRepository.InsertAsync( |
||||
|
new Client( |
||||
|
_guidGenerator.Create(), |
||||
|
name |
||||
|
) |
||||
|
{ |
||||
|
ClientName = name, |
||||
|
ProtocolType = "oidc", |
||||
|
Description = name, |
||||
|
AlwaysIncludeUserClaimsInIdToken = true, |
||||
|
AllowOfflineAccess = true, |
||||
|
AbsoluteRefreshTokenLifetime = 10800, //3 hours
|
||||
|
AccessTokenLifetime = 7200, //2 hours
|
||||
|
AuthorizationCodeLifetime = 300, |
||||
|
IdentityTokenLifetime = 300, |
||||
|
RequireConsent = false |
||||
|
}, |
||||
|
autoSave: true |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
foreach (var scope in scopes) |
||||
|
{ |
||||
|
if (client.FindScope(scope) == null) |
||||
|
{ |
||||
|
client.AddScope(scope); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
foreach (var grantType in grantTypes) |
||||
|
{ |
||||
|
if (client.FindGrantType(grantType) == null) |
||||
|
{ |
||||
|
client.AddGrantType(grantType); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (client.FindSecret(secret) == null) |
||||
|
{ |
||||
|
client.AddSecret(secret); |
||||
|
} |
||||
|
|
||||
|
if (redirectUri != null) |
||||
|
{ |
||||
|
if (client.FindRedirectUri(redirectUri) == null) |
||||
|
{ |
||||
|
client.AddRedirectUri(redirectUri); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (postLogoutRedirectUri != null) |
||||
|
{ |
||||
|
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) |
||||
|
{ |
||||
|
client.AddPostLogoutRedirectUri(postLogoutRedirectUri); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (corsOrigins != null) |
||||
|
{ |
||||
|
var corsOriginsSplit = corsOrigins.Split(";"); |
||||
|
foreach (var corsOrigin in corsOriginsSplit) |
||||
|
{ |
||||
|
if (client.FindCorsOrigin(corsOrigin) == null) |
||||
|
{ |
||||
|
client.AddCorsOrigin(corsOrigin); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (permissions != null) |
||||
|
{ |
||||
|
await _permissionDataSeeder.SeedAsync(ClientPermissionValueProvider.ProviderName, name, permissions); |
||||
|
} |
||||
|
|
||||
|
return await _clientRepository.UpdateAsync(client); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,85 @@ |
|||||
|
using LINGYUN.Abp.WeChat; |
||||
|
using LINGYUN.Abp.WeChat.Security.Claims; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.IdentityServer.IdentityResources; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator.DataSeeder; |
||||
|
|
||||
|
public class WeChatResourceDataSeeder : IWeChatResourceDataSeeder, ITransientDependency |
||||
|
{ |
||||
|
protected IIdentityClaimTypeRepository ClaimTypeRepository { get; } |
||||
|
protected IIdentityResourceRepository IdentityResourceRepository { get; } |
||||
|
protected IGuidGenerator GuidGenerator { get; } |
||||
|
|
||||
|
public WeChatResourceDataSeeder( |
||||
|
IIdentityResourceRepository identityResourceRepository, |
||||
|
IGuidGenerator guidGenerator, |
||||
|
IIdentityClaimTypeRepository claimTypeRepository) |
||||
|
{ |
||||
|
IdentityResourceRepository = identityResourceRepository; |
||||
|
GuidGenerator = guidGenerator; |
||||
|
ClaimTypeRepository = claimTypeRepository; |
||||
|
} |
||||
|
|
||||
|
public async virtual Task CreateStandardResourcesAsync() |
||||
|
{ |
||||
|
var wechatClaimTypes = new string[] |
||||
|
{ |
||||
|
AbpWeChatClaimTypes.AvatarUrl, |
||||
|
AbpWeChatClaimTypes.City, |
||||
|
AbpWeChatClaimTypes.Country, |
||||
|
AbpWeChatClaimTypes.NickName, |
||||
|
AbpWeChatClaimTypes.OpenId, |
||||
|
AbpWeChatClaimTypes.Privilege, |
||||
|
AbpWeChatClaimTypes.Province, |
||||
|
AbpWeChatClaimTypes.Sex, |
||||
|
AbpWeChatClaimTypes.UnionId |
||||
|
}; |
||||
|
|
||||
|
var wechatResource = new IdentityServer4.Models.IdentityResource( |
||||
|
AbpWeChatGlobalConsts.ProfileKey, |
||||
|
AbpWeChatGlobalConsts.DisplayName, |
||||
|
wechatClaimTypes); |
||||
|
|
||||
|
foreach (var claimType in wechatClaimTypes) |
||||
|
{ |
||||
|
await AddClaimTypeIfNotExistsAsync(claimType); |
||||
|
} |
||||
|
|
||||
|
await AddIdentityResourceIfNotExistsAsync(wechatResource); |
||||
|
} |
||||
|
|
||||
|
protected async virtual Task AddIdentityResourceIfNotExistsAsync(IdentityServer4.Models.IdentityResource resource) |
||||
|
{ |
||||
|
if (await IdentityResourceRepository.CheckNameExistAsync(resource.Name)) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
await IdentityResourceRepository.InsertAsync( |
||||
|
new IdentityResource( |
||||
|
GuidGenerator.Create(), |
||||
|
resource |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
protected async virtual Task AddClaimTypeIfNotExistsAsync(string claimType) |
||||
|
{ |
||||
|
if (await ClaimTypeRepository.AnyAsync(claimType)) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
await ClaimTypeRepository.InsertAsync( |
||||
|
new IdentityClaimType( |
||||
|
GuidGenerator.Create(), |
||||
|
claimType, |
||||
|
isStatic: true |
||||
|
) |
||||
|
); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.Tenants; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class IdentityServerDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<IdentityServerDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public IdentityServerDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IDbSchemaMigrator dbSchemaMigrator, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<IdentityServerDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
// 迁移租户数据
|
||||
|
await _dbSchemaMigrator.MigrateAsync<IdentityServerMigrationsDbContext>( |
||||
|
(connectionString, builder) => |
||||
|
{ |
||||
|
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new IdentityServerMigrationsDbContext(builder.Options); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(tenant?.Id); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
return Path.Combine(slnDirectoryPath, "LY.MicroService.BackendAdmin.DbMigrator"); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
|
||||
|
// parent host
|
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,25 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
using Volo.Abp.Identity.EntityFrameworkCore; |
||||
|
using Volo.Abp.IdentityServer.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
[ConnectionStringName("IdentityServerDbMigrator")] |
||||
|
public class IdentityServerMigrationsDbContext : AbpDbContext<IdentityServerMigrationsDbContext> |
||||
|
{ |
||||
|
public IdentityServerMigrationsDbContext(DbContextOptions<IdentityServerMigrationsDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigureIdentity(); |
||||
|
modelBuilder.ConfigureIdentityServer(); |
||||
|
} |
||||
|
} |
||||
@ -1,29 +1,29 @@ |
|||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.EntityFrameworkCore.Design; |
using Microsoft.EntityFrameworkCore.Design; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.Configuration; |
||||
using System.IO; |
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; |
||||
namespace LY.MicroService.IdentityServer.EntityFrameworkCore; |
|
||||
|
public class IdentityServerMigrationsDbContextFactory : IDesignTimeDbContextFactory<IdentityServerMigrationsDbContext> |
||||
public class IdentityServertMigrationsDbContextFactory : IDesignTimeDbContextFactory<IdentityServertMigrationsDbContext> |
|
||||
{ |
{ |
||||
public IdentityServertMigrationsDbContext CreateDbContext(string[] args) |
public IdentityServerMigrationsDbContext CreateDbContext(string[] args) |
||||
{ |
{ |
||||
var configuration = BuildConfiguration(); |
var configuration = BuildConfiguration(); |
||||
var connectionString = configuration.GetConnectionString("Default"); |
var connectionString = configuration.GetConnectionString("Default"); |
||||
|
|
||||
var builder = new DbContextOptionsBuilder<IdentityServertMigrationsDbContext>() |
var builder = new DbContextOptionsBuilder<IdentityServerMigrationsDbContext>() |
||||
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
return new IdentityServertMigrationsDbContext(builder.Options); |
return new IdentityServerMigrationsDbContext(builder!.Options); |
||||
} |
} |
||||
|
|
||||
private static IConfigurationRoot BuildConfiguration() |
private static IConfigurationRoot BuildConfiguration() |
||||
{ |
{ |
||||
var builder = new ConfigurationBuilder() |
var builder = new ConfigurationBuilder() |
||||
.SetBasePath(Directory.GetCurrentDirectory()) |
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
.AddJsonFile("appsettings.Development.json", optional: false); |
.AddJsonFile("appsettings.json", optional: false) |
||||
|
.AddJsonFile("appsettings.Development.json", optional: true); |
||||
|
|
||||
return builder.Build(); |
return builder.Build(); |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
using LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Serilog; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator; |
||||
|
|
||||
|
public class IdentityServerDbMigratorHostedService : IHostedService |
||||
|
{ |
||||
|
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public IdentityServerDbMigratorHostedService( |
||||
|
IHostApplicationLifetime hostApplicationLifetime, |
||||
|
IConfiguration configuration) |
||||
|
{ |
||||
|
_hostApplicationLifetime = hostApplicationLifetime; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public async Task StartAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
using var application = await AbpApplicationFactory |
||||
|
.CreateAsync<IdentityServerDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(_configuration); |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
options.AddDataMigrationEnvironment(); |
||||
|
}); |
||||
|
await application.InitializeAsync(); |
||||
|
|
||||
|
await application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<IdentityServerDbMigrationService>() |
||||
|
.MigrateAsync(); |
||||
|
|
||||
|
await application.ShutdownAsync(); |
||||
|
|
||||
|
_hostApplicationLifetime.StopApplication(); |
||||
|
} |
||||
|
|
||||
|
public Task StopAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,18 @@ |
|||||
|
using LY.MicroService.IdentityServer.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator; |
||||
|
public partial class IdentityServerDbMigratorModule |
||||
|
{ |
||||
|
private void ConfigureDbContext(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpDbContext<IdentityServerMigrationsDbContext>(); |
||||
|
|
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Identity.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.IdentityServer.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.WeChat; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpSaasEntityFrameworkCoreModule), |
||||
|
typeof(AbpIdentityEntityFrameworkCoreModule), |
||||
|
typeof(AbpIdentityServerEntityFrameworkCoreModule), |
||||
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpWeChatModule), |
||||
|
typeof(AbpDataDbMigratorModule), |
||||
|
typeof(AbpAutofacModule) |
||||
|
)] |
||||
|
public partial class IdentityServerDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
ConfigureDbContext(context.Services); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\identityServer\LINGYUN.Abp.IdentityServer.EntityFrameworkCore\LINGYUN.Abp.IdentityServer.EntityFrameworkCore.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\identity\LINGYUN.Abp.Identity.EntityFrameworkCore\LINGYUN.Abp.Identity.EntityFrameworkCore.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\wechat\LINGYUN.Abp.WeChat\LINGYUN.Abp.WeChat.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Folder Include="Migrations\" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
File diff suppressed because it is too large
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -0,0 +1,40 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
|
||||
|
namespace LY.MicroService.IdentityServer.DbMigrator; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public async static Task Main(string[] args) |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("LY.MicroService.IdentityServer.DbMigrator", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("LY.MicroService.IdentityServer.DbMigrator", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.Console() |
||||
|
.WriteTo.File("Logs/migrations.txt") |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
await CreateHostBuilder(args).RunConsoleAsync(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) |
||||
|
{ |
||||
|
return Host.CreateDefaultBuilder(args) |
||||
|
.AddAppSettingsSecretsJson() |
||||
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
||||
|
.ConfigureServices((hostContext, services) => |
||||
|
{ |
||||
|
services.AddHostedService<IdentityServerDbMigratorHostedService>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"profiles": { |
||||
|
"LY.MicroService.IdentityServer.DbMigrator": { |
||||
|
"commandName": "Project", |
||||
|
"dotnetRunMessages": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using LINGYUN.Abp; |
||||
@ -0,0 +1,93 @@ |
|||||
|
{ |
||||
|
"App": { |
||||
|
"CorsOrigins": "http://127.0.0.1:3100" |
||||
|
}, |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", |
||||
|
"AbpIdentity": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", |
||||
|
"AbpIdentityServer": "Server=127.0.0.1;Database=IdentityServer-v70;User Id=root;Password=123456", |
||||
|
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"IdentityServer": { |
||||
|
"Clients": { |
||||
|
"AuthVueAdmin": { |
||||
|
"ClientId": "vue-admin-client", |
||||
|
"RootUrl": "http://127.0.0.1:3100/" |
||||
|
}, |
||||
|
"InternalService": { |
||||
|
"ClientId": "InternalServiceClient" |
||||
|
} |
||||
|
} |
||||
|
}, |
||||
|
"StringEncryption": { |
||||
|
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
|
"InitVectorBytes": "s83ng0abvd02js84", |
||||
|
"DefaultSalt": "sf&5)s3#" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Information", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Debug-.log", |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Info-.log", |
||||
|
"restrictedToMinimumLevel": "Information", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Warn-.log", |
||||
|
"restrictedToMinimumLevel": "Warning", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Error-.log", |
||||
|
"restrictedToMinimumLevel": "Error", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Fatal-.log", |
||||
|
"restrictedToMinimumLevel": "Fatal", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.Tenants; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class LocalizationManagementDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<LocalizationManagementDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public LocalizationManagementDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IDbSchemaMigrator dbSchemaMigrator, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<LocalizationManagementDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
// 迁移租户数据
|
||||
|
await _dbSchemaMigrator.MigrateAsync<LocalizationManagementMigrationsDbContext>( |
||||
|
(connectionString, builder) => |
||||
|
{ |
||||
|
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new LocalizationManagementMigrationsDbContext(builder.Options); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(tenant?.Id); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
return Path.Combine(slnDirectoryPath, "LY.MicroService.LocalizationManagement.DbMigrator"); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
|
||||
|
// parent host
|
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
[ConnectionStringName("LocalizationManagementDbMigrator")] |
||||
|
public class LocalizationManagementMigrationsDbContext : AbpDbContext<LocalizationManagementMigrationsDbContext> |
||||
|
{ |
||||
|
public LocalizationManagementMigrationsDbContext(DbContextOptions<LocalizationManagementMigrationsDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigureLocalization(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class LocalizationManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory<LocalizationManagementMigrationsDbContext> |
||||
|
{ |
||||
|
public LocalizationManagementMigrationsDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
var configuration = BuildConfiguration(); |
||||
|
var connectionString = configuration.GetConnectionString("Default"); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<LocalizationManagementMigrationsDbContext>() |
||||
|
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new LocalizationManagementMigrationsDbContext(builder!.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
|
.AddJsonFile("appsettings.json", optional: false) |
||||
|
.AddJsonFile("appsettings.Development.json", optional: true); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,55 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\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\lt\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore\LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Folder Include="Migrations\" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,51 @@ |
|||||
|
using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Serilog; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator; |
||||
|
|
||||
|
public class LocalizationManagementDbMigratorHostedService : IHostedService |
||||
|
{ |
||||
|
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public LocalizationManagementDbMigratorHostedService( |
||||
|
IHostApplicationLifetime hostApplicationLifetime, |
||||
|
IConfiguration configuration) |
||||
|
{ |
||||
|
_hostApplicationLifetime = hostApplicationLifetime; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public async Task StartAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
using var application = await AbpApplicationFactory |
||||
|
.CreateAsync<LocalizationManagementDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(_configuration); |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
options.AddDataMigrationEnvironment(); |
||||
|
}); |
||||
|
await application.InitializeAsync(); |
||||
|
|
||||
|
await application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<LocalizationManagementDbMigrationService>() |
||||
|
.MigrateAsync(); |
||||
|
|
||||
|
await application.ShutdownAsync(); |
||||
|
|
||||
|
_hostApplicationLifetime.StopApplication(); |
||||
|
} |
||||
|
|
||||
|
public Task StopAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,18 @@ |
|||||
|
using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator; |
||||
|
public partial class LocalizationManagementDbMigratorModule |
||||
|
{ |
||||
|
private void ConfigureDbContext(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpDbContext<LocalizationManagementMigrationsDbContext>(); |
||||
|
|
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,27 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.LocalizationManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpSaasEntityFrameworkCoreModule), |
||||
|
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpLocalizationManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpDataDbMigratorModule), |
||||
|
typeof(AbpAutofacModule) |
||||
|
)] |
||||
|
public partial class LocalizationManagementDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
ConfigureDbContext(context.Services); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,169 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(LocalizationManagementMigrationsDbContext))] |
||||
|
[Migration("20230109093938_Initial-Localization-Management")] |
||||
|
partial class InitialLocalizationManagement |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("CultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("CultureName"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<bool>("Enable") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<string>("FlagIcon") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("FlagIcon"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("UiCultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("UiCultureName"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("CultureName"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationLanguages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<bool>("Enable") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationResources", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("CultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("CultureName"); |
||||
|
|
||||
|
b.Property<string>("Key") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("Key"); |
||||
|
|
||||
|
b.Property<string>("ResourceName") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)") |
||||
|
.HasColumnName("Value"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Key"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationTexts", (string)null); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,116 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class InitialLocalizationManagement : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AlterDatabase() |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpLocalizationLanguages", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Enable = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true), |
||||
|
CultureName = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
UiCultureName = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
FlagIcon = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpLocalizationLanguages", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpLocalizationResources", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Enable = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true), |
||||
|
Name = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpLocalizationResources", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AbpLocalizationTexts", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<int>(type: "int", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
CultureName = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Key = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Value = table.Column<string>(type: "varchar(2048)", maxLength: 2048, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ResourceName = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AbpLocalizationTexts", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpLocalizationLanguages_CultureName", |
||||
|
table: "AbpLocalizationLanguages", |
||||
|
column: "CultureName"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpLocalizationResources_Name", |
||||
|
table: "AbpLocalizationResources", |
||||
|
column: "Name"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AbpLocalizationTexts_Key", |
||||
|
table: "AbpLocalizationTexts", |
||||
|
column: "Key"); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpLocalizationLanguages"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpLocalizationResources"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AbpLocalizationTexts"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,174 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(LocalizationManagementMigrationsDbContext))] |
||||
|
[Migration("20230110091142_Add-Default-Culture-Name-With-Resource-Record")] |
||||
|
partial class AddDefaultCultureNameWithResourceRecord |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("CultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("CultureName"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<bool>("Enable") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<string>("FlagIcon") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("FlagIcon"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("UiCultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("UiCultureName"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("CultureName"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationLanguages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("DefaultCultureName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DefaultCultureName"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<bool>("Enable") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationResources", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("CultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("CultureName"); |
||||
|
|
||||
|
b.Property<string>("Key") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("Key"); |
||||
|
|
||||
|
b.Property<string>("ResourceName") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)") |
||||
|
.HasColumnName("Value"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Key"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationTexts", (string)null); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class AddDefaultCultureNameWithResourceRecord : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AddColumn<string>( |
||||
|
name: "DefaultCultureName", |
||||
|
table: "AbpLocalizationResources", |
||||
|
type: "varchar(64)", |
||||
|
maxLength: 64, |
||||
|
nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropColumn( |
||||
|
name: "DefaultCultureName", |
||||
|
table: "AbpLocalizationResources"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,171 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.LocalizationManagement.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(LocalizationManagementMigrationsDbContext))] |
||||
|
partial class LocalizationManagementMigrationsDbContextModelSnapshot : ModelSnapshot |
||||
|
{ |
||||
|
protected override void BuildModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Language", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("CultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("CultureName"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<bool>("Enable") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<string>("FlagIcon") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("FlagIcon"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("UiCultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("UiCultureName"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("CultureName"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationLanguages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Resource", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("DefaultCultureName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DefaultCultureName"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<bool>("Enable") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationResources", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.LocalizationManagement.Text", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("CultureName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)") |
||||
|
.HasColumnName("CultureName"); |
||||
|
|
||||
|
b.Property<string>("Key") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("Key"); |
||||
|
|
||||
|
b.Property<string>("ResourceName") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<string>("Value") |
||||
|
.HasMaxLength(2048) |
||||
|
.HasColumnType("varchar(2048)") |
||||
|
.HasColumnName("Value"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Key"); |
||||
|
|
||||
|
b.ToTable("AbpLocalizationTexts", (string)null); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
|
||||
|
namespace LY.MicroService.LocalizationManagement.DbMigrator; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public async static Task Main(string[] args) |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("LY.MicroService.LocalizationManagement.DbMigrator", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("LY.MicroService.LocalizationManagement.DbMigrator", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.Console() |
||||
|
.WriteTo.File("Logs/migrations.txt") |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
await CreateHostBuilder(args).RunConsoleAsync(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) |
||||
|
{ |
||||
|
return Host.CreateDefaultBuilder(args) |
||||
|
.AddAppSettingsSecretsJson() |
||||
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
||||
|
.ConfigureServices((hostContext, services) => |
||||
|
{ |
||||
|
services.AddHostedService<LocalizationManagementDbMigratorHostedService>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"profiles": { |
||||
|
"LY.MicroService.LocalizationManagement.DbMigrator": { |
||||
|
"commandName": "Project", |
||||
|
"dotnetRunMessages": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using LINGYUN.Abp; |
||||
@ -0,0 +1,79 @@ |
|||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"StringEncryption": { |
||||
|
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
|
"InitVectorBytes": "s83ng0abvd02js84", |
||||
|
"DefaultSalt": "sf&5)s3#" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Information", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Debug-.log", |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Info-.log", |
||||
|
"restrictedToMinimumLevel": "Information", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Warn-.log", |
||||
|
"restrictedToMinimumLevel": "Warning", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Error-.log", |
||||
|
"restrictedToMinimumLevel": "Error", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Fatal-.log", |
||||
|
"restrictedToMinimumLevel": "Fatal", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.Tenants; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class PlatformDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<PlatformDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public PlatformDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IDbSchemaMigrator dbSchemaMigrator, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<PlatformDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
// 迁移租户数据
|
||||
|
await _dbSchemaMigrator.MigrateAsync<PlatformMigrationsDbContext>( |
||||
|
(connectionString, builder) => |
||||
|
{ |
||||
|
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new PlatformMigrationsDbContext(builder.Options); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(tenant?.Id); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
return Path.Combine(slnDirectoryPath, "LY.MicroService.Platform.DbMigrator"); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
|
||||
|
// parent host
|
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using LINGYUN.Platform.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
[ConnectionStringName("PlatformDbMigrator")] |
||||
|
public class PlatformMigrationsDbContext : AbpDbContext<PlatformMigrationsDbContext> |
||||
|
{ |
||||
|
public PlatformMigrationsDbContext(DbContextOptions<PlatformMigrationsDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigurePlatform(); |
||||
|
} |
||||
|
} |
||||
@ -1,21 +1,20 @@ |
|||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.EntityFrameworkCore.Design; |
using Microsoft.EntityFrameworkCore.Design; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.Configuration; |
||||
using System.IO; |
|
||||
|
|
||||
namespace LY.MicroService.WorkflowManagement.EntityFrameworkCore; |
namespace LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
public class WorkflowManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory<WorkflowManagementMigrationsDbContext> |
public class PlatformMigrationsDbContextFactory : IDesignTimeDbContextFactory<PlatformMigrationsDbContext> |
||||
{ |
{ |
||||
public WorkflowManagementMigrationsDbContext CreateDbContext(string[] args) |
public PlatformMigrationsDbContext CreateDbContext(string[] args) |
||||
{ |
{ |
||||
var configuration = BuildConfiguration(); |
var configuration = BuildConfiguration(); |
||||
var connectionString = configuration.GetConnectionString("WorkflowManagement"); |
var connectionString = configuration.GetConnectionString("Default"); |
||||
|
|
||||
var builder = new DbContextOptionsBuilder<WorkflowManagementMigrationsDbContext>() |
var builder = new DbContextOptionsBuilder<PlatformMigrationsDbContext>() |
||||
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
return new WorkflowManagementMigrationsDbContext(builder.Options); |
return new PlatformMigrationsDbContext(builder!.Options); |
||||
} |
} |
||||
|
|
||||
private static IConfigurationRoot BuildConfiguration() |
private static IConfigurationRoot BuildConfiguration() |
||||
@ -0,0 +1,56 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\platform\LINGYUN.Abp.UI.Navigation.VueVbenAdmin\LINGYUN.Abp.UI.Navigation.VueVbenAdmin.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\platform\LINGYUN.Platform.EntityFrameworkCore\LINGYUN.Platform.EntityFrameworkCore.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Folder Include="Migrations\" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,772 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(PlatformMigrationsDbContext))] |
||||
|
[Migration("20230110015904_Initial-Platform")] |
||||
|
partial class InitialPlatform |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Code"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<bool>("IsStatic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("ParentId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AppPlatformDatas", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowBeNull") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid>("DataId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DefaultValue") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DefaultValue"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<bool>("IsStatic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("ValueType") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("DataId"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AppPlatformDataItems", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid>("DataId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Framework") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Framework"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("Path") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Path"); |
||||
|
|
||||
|
b.Property<string>("Redirect") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Redirect"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppPlatformLayouts", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(23) |
||||
|
.HasColumnType("varchar(23)") |
||||
|
.HasColumnName("Code"); |
||||
|
|
||||
|
b.Property<string>("Component") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Component"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Framework") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Framework"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<bool>("IsPublic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("LayoutId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("ParentId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Path") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Path"); |
||||
|
|
||||
|
b.Property<string>("Redirect") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Redirect"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppPlatformMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("MenuId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("RoleName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("RoleName"); |
||||
|
|
||||
|
b.Property<bool>("Startup") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("RoleName", "MenuId"); |
||||
|
|
||||
|
b.ToTable("AppPlatformRoleMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("AliasName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("AliasName"); |
||||
|
|
||||
|
b.Property<string>("Color") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Color"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("Framework") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Framework"); |
||||
|
|
||||
|
b.Property<string>("Icon") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("Icon"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("MenuId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("Path") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Path"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("UserId", "MenuId"); |
||||
|
|
||||
|
b.ToTable("AppPlatformUserFavoriteMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("MenuId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("Startup") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("UserId", "MenuId"); |
||||
|
|
||||
|
b.ToTable("AppPlatformUserMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Authors") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("Authors"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("ForceUpdate") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<int>("Level") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("Note") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Note"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<string>("Version") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Version"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "Version"); |
||||
|
|
||||
|
b.ToTable("AppPlatformPackages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Authors") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("Authors"); |
||||
|
|
||||
|
b.Property<string>("ContentType") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("ContentType"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<int>("DownloadCount") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("License") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("License"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid>("PackageId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("SHA256") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("SHA256"); |
||||
|
|
||||
|
b.Property<long?>("Size") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("Summary") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Summary"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("Url") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("Url"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("PackageId", "Name"); |
||||
|
|
||||
|
b.ToTable("AppPlatformPackageBlobs", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Platform.Datas.Data", null) |
||||
|
.WithMany("Items") |
||||
|
.HasForeignKey("DataId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Platform.Packages.Package", "Package") |
||||
|
.WithMany("Blobs") |
||||
|
.HasForeignKey("PackageId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("Package"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => |
||||
|
{ |
||||
|
b.Navigation("Items"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => |
||||
|
{ |
||||
|
b.Navigation("Blobs"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,399 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class InitialPlatform : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AlterDatabase() |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformDatas", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Code = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsStatic = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformDatas", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformLayouts", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Framework = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DataId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Path = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Redirect = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformLayouts", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformMenus", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Framework = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Code = table.Column<string>(type: "varchar(23)", maxLength: 23, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Component = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ParentId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LayoutId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
IsPublic = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Path = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Redirect = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformMenus", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformPackages", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Note = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Version = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ForceUpdate = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
Authors = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Level = table.Column<int>(type: "int", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformPackages", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformRoleMenus", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
MenuId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
RoleName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Startup = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformRoleMenus", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformUserFavoriteMenus", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
MenuId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
AliasName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Color = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Framework = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Path = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Icon = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformUserFavoriteMenus", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformUserMenus", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
MenuId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Startup = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformUserMenus", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformDataItems", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DefaultValue = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
AllowBeNull = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: true), |
||||
|
IsStatic = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
ValueType = table.Column<int>(type: "int", nullable: false), |
||||
|
DataId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
IsDeleted = table.Column<bool>(type: "tinyint(1)", nullable: false, defaultValue: false), |
||||
|
DeleterId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
DeletionTime = table.Column<DateTime>(type: "datetime(6)", nullable: true) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformDataItems", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AppPlatformDataItems_AppPlatformDatas_DataId", |
||||
|
column: x => x.DataId, |
||||
|
principalTable: "AppPlatformDatas", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppPlatformPackageBlobs", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<int>(type: "int", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
PackageId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Url = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Size = table.Column<long>(type: "bigint", nullable: true), |
||||
|
Summary = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
UpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
License = table.Column<string>(type: "varchar(1024)", maxLength: 1024, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Authors = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ContentType = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
SHA256 = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DownloadCount = table.Column<int>(type: "int", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppPlatformPackageBlobs", x => x.Id); |
||||
|
table.ForeignKey( |
||||
|
name: "FK_AppPlatformPackageBlobs_AppPlatformPackages_PackageId", |
||||
|
column: x => x.PackageId, |
||||
|
principalTable: "AppPlatformPackages", |
||||
|
principalColumn: "Id", |
||||
|
onDelete: ReferentialAction.Cascade); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformDataItems_DataId", |
||||
|
table: "AppPlatformDataItems", |
||||
|
column: "DataId"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformDataItems_Name", |
||||
|
table: "AppPlatformDataItems", |
||||
|
column: "Name"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformDatas_Name", |
||||
|
table: "AppPlatformDatas", |
||||
|
column: "Name"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformPackageBlobs_PackageId_Name", |
||||
|
table: "AppPlatformPackageBlobs", |
||||
|
columns: new[] { "PackageId", "Name" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformPackages_Name_Version", |
||||
|
table: "AppPlatformPackages", |
||||
|
columns: new[] { "Name", "Version" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformRoleMenus_RoleName_MenuId", |
||||
|
table: "AppPlatformRoleMenus", |
||||
|
columns: new[] { "RoleName", "MenuId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformUserFavoriteMenus_UserId_MenuId", |
||||
|
table: "AppPlatformUserFavoriteMenus", |
||||
|
columns: new[] { "UserId", "MenuId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppPlatformUserMenus_UserId_MenuId", |
||||
|
table: "AppPlatformUserMenus", |
||||
|
columns: new[] { "UserId", "MenuId" }); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformDataItems"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformLayouts"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformMenus"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformPackageBlobs"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformRoleMenus"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformUserFavoriteMenus"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformUserMenus"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformDatas"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppPlatformPackages"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,769 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(PlatformMigrationsDbContext))] |
||||
|
partial class PlatformMigrationsDbContextModelSnapshot : ModelSnapshot |
||||
|
{ |
||||
|
protected override void BuildModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Code"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<bool>("IsStatic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("ParentId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AppPlatformDatas", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowBeNull") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(true); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid>("DataId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("DefaultValue") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DefaultValue"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<bool>("IsStatic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("ValueType") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("DataId"); |
||||
|
|
||||
|
b.HasIndex("Name"); |
||||
|
|
||||
|
b.ToTable("AppPlatformDataItems", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Layouts.Layout", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid>("DataId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Framework") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Framework"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("Path") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Path"); |
||||
|
|
||||
|
b.Property<string>("Redirect") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Redirect"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppPlatformLayouts", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.Menu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Code") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(23) |
||||
|
.HasColumnType("varchar(23)") |
||||
|
.HasColumnName("Code"); |
||||
|
|
||||
|
b.Property<string>("Component") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Component"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Framework") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Framework"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<bool>("IsPublic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("LayoutId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid?>("ParentId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Path") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Path"); |
||||
|
|
||||
|
b.Property<string>("Redirect") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Redirect"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppPlatformMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.RoleMenu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("MenuId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("RoleName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("RoleName"); |
||||
|
|
||||
|
b.Property<bool>("Startup") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("RoleName", "MenuId"); |
||||
|
|
||||
|
b.ToTable("AppPlatformRoleMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.UserFavoriteMenu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("AliasName") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("AliasName"); |
||||
|
|
||||
|
b.Property<string>("Color") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Color"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasColumnName("DisplayName"); |
||||
|
|
||||
|
b.Property<string>("Framework") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Framework"); |
||||
|
|
||||
|
b.Property<string>("Icon") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("Icon"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("MenuId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("Path") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Path"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("UserId", "MenuId"); |
||||
|
|
||||
|
b.ToTable("AppPlatformUserFavoriteMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Menus.UserMenu", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<Guid>("MenuId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("Startup") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("UserId", "MenuId"); |
||||
|
|
||||
|
b.ToTable("AppPlatformUserMenus", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("Authors") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("Authors"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<Guid?>("DeleterId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("DeleterId"); |
||||
|
|
||||
|
b.Property<DateTime?>("DeletionTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("DeletionTime"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Description"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("ForceUpdate") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("IsDeleted") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("tinyint(1)") |
||||
|
.HasDefaultValue(false) |
||||
|
.HasColumnName("IsDeleted"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<int>("Level") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<string>("Note") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Note"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<string>("Version") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)") |
||||
|
.HasColumnName("Version"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("Name", "Version"); |
||||
|
|
||||
|
b.ToTable("AppPlatformPackages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => |
||||
|
{ |
||||
|
b.Property<int>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Authors") |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)") |
||||
|
.HasColumnName("Authors"); |
||||
|
|
||||
|
b.Property<string>("ContentType") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("ContentType"); |
||||
|
|
||||
|
b.Property<DateTime>("CreatedAt") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<int>("DownloadCount") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("License") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("License"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)") |
||||
|
.HasColumnName("Name"); |
||||
|
|
||||
|
b.Property<Guid>("PackageId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("SHA256") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)") |
||||
|
.HasColumnName("SHA256"); |
||||
|
|
||||
|
b.Property<long?>("Size") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("Summary") |
||||
|
.HasMaxLength(1024) |
||||
|
.HasColumnType("varchar(1024)") |
||||
|
.HasColumnName("Summary"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<DateTime?>("UpdatedAt") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("Url") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)") |
||||
|
.HasColumnName("Url"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("PackageId", "Name"); |
||||
|
|
||||
|
b.ToTable("AppPlatformPackageBlobs", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.DataItem", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Platform.Datas.Data", null) |
||||
|
.WithMany("Items") |
||||
|
.HasForeignKey("DataId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.PackageBlob", b => |
||||
|
{ |
||||
|
b.HasOne("LINGYUN.Platform.Packages.Package", "Package") |
||||
|
.WithMany("Blobs") |
||||
|
.HasForeignKey("PackageId") |
||||
|
.OnDelete(DeleteBehavior.Cascade) |
||||
|
.IsRequired(); |
||||
|
|
||||
|
b.Navigation("Package"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Datas.Data", b => |
||||
|
{ |
||||
|
b.Navigation("Items"); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Platform.Packages.Package", b => |
||||
|
{ |
||||
|
b.Navigation("Blobs"); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Serilog; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator; |
||||
|
|
||||
|
public class PlatformDbMigratorHostedService : IHostedService |
||||
|
{ |
||||
|
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public PlatformDbMigratorHostedService( |
||||
|
IHostApplicationLifetime hostApplicationLifetime, |
||||
|
IConfiguration configuration) |
||||
|
{ |
||||
|
_hostApplicationLifetime = hostApplicationLifetime; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public async Task StartAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
using var application = await AbpApplicationFactory |
||||
|
.CreateAsync<PlatformDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(_configuration); |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
options.AddDataMigrationEnvironment(); |
||||
|
}); |
||||
|
await application.InitializeAsync(); |
||||
|
|
||||
|
await application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<PlatformDbMigrationService>() |
||||
|
.MigrateAsync(); |
||||
|
|
||||
|
await application.ShutdownAsync(); |
||||
|
|
||||
|
_hostApplicationLifetime.StopApplication(); |
||||
|
} |
||||
|
|
||||
|
public Task StopAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,18 @@ |
|||||
|
using LY.MicroService.Platform.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator; |
||||
|
public partial class PlatformDbMigratorModule |
||||
|
{ |
||||
|
private void ConfigureDbContext(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpDbContext<PlatformMigrationsDbContext>(); |
||||
|
|
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.UI.Navigation.VueVbenAdmin; |
||||
|
using LINGYUN.Platform.EntityFrameworkCore; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpSaasEntityFrameworkCoreModule), |
||||
|
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
||||
|
typeof(PlatformEntityFrameworkCoreModule), |
||||
|
typeof(AbpUINavigationVueVbenAdminModule), |
||||
|
typeof(AbpDataDbMigratorModule), |
||||
|
typeof(AbpAutofacModule) |
||||
|
)] |
||||
|
public partial class PlatformDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
ConfigureDbContext(context.Services); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
|
||||
|
namespace LY.MicroService.Platform.DbMigrator; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public async static Task Main(string[] args) |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("LY.MicroService.Platform.DbMigrator", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("LY.MicroService.Platform.DbMigrator", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.Console() |
||||
|
.WriteTo.File("Logs/migrations.txt") |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
await CreateHostBuilder(args).RunConsoleAsync(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) |
||||
|
{ |
||||
|
return Host.CreateDefaultBuilder(args) |
||||
|
.AddAppSettingsSecretsJson() |
||||
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
||||
|
.ConfigureServices((hostContext, services) => |
||||
|
{ |
||||
|
services.AddHostedService<PlatformDbMigratorHostedService>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"profiles": { |
||||
|
"LY.MicroService.Platform.DbMigrator": { |
||||
|
"commandName": "Project", |
||||
|
"dotnetRunMessages": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using LINGYUN.Abp; |
||||
@ -0,0 +1,80 @@ |
|||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AppPlatform": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"StringEncryption": { |
||||
|
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
|
"InitVectorBytes": "s83ng0abvd02js84", |
||||
|
"DefaultSalt": "sf&5)s3#" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Information", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Debug-.log", |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Info-.log", |
||||
|
"restrictedToMinimumLevel": "Information", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Warn-.log", |
||||
|
"restrictedToMinimumLevel": "Warning", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Error-.log", |
||||
|
"restrictedToMinimumLevel": "Error", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Fatal-.log", |
||||
|
"restrictedToMinimumLevel": "Fatal", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.Tenants; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class RealtimeMessageDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<RealtimeMessageDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public RealtimeMessageDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IDbSchemaMigrator dbSchemaMigrator, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<RealtimeMessageDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
// 迁移租户数据
|
||||
|
await _dbSchemaMigrator.MigrateAsync<RealtimeMessageMigrationsDbContext>( |
||||
|
(connectionString, builder) => |
||||
|
{ |
||||
|
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new RealtimeMessageMigrationsDbContext(builder.Options); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(tenant?.Id); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
return Path.Combine(slnDirectoryPath, "LY.MicroService.RealtimeMessage.DbMigrator"); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
|
||||
|
// parent host
|
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.Notifications.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
[ConnectionStringName("RealtimeMessageDbMigrator")] |
||||
|
public class RealtimeMessageMigrationsDbContext : AbpDbContext<RealtimeMessageMigrationsDbContext> |
||||
|
{ |
||||
|
public RealtimeMessageMigrationsDbContext(DbContextOptions<RealtimeMessageMigrationsDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigureNotifications(); |
||||
|
modelBuilder.ConfigureNotificationsDefinition(); |
||||
|
modelBuilder.ConfigureMessageService(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class RealtimeMessageMigrationsDbContextFactory : IDesignTimeDbContextFactory<RealtimeMessageMigrationsDbContext> |
||||
|
{ |
||||
|
public RealtimeMessageMigrationsDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
var configuration = BuildConfiguration(); |
||||
|
var connectionString = configuration.GetConnectionString("Default"); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<RealtimeMessageMigrationsDbContext>() |
||||
|
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new RealtimeMessageMigrationsDbContext(builder!.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
|
.AddJsonFile("appsettings.json", optional: false) |
||||
|
.AddJsonFile("appsettings.Development.json", optional: true); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,56 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\common\LINGYUN.Abp.Data.DbMigrator\LINGYUN.Abp.Data.DbMigrator.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\message\LINGYUN.Abp.MessageService.EntityFrameworkCore\LINGYUN.Abp.MessageService.EntityFrameworkCore.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\notifications\LINGYUN.Abp.Notifications.EntityFrameworkCore\LINGYUN.Abp.Notifications.EntityFrameworkCore.csproj" /> |
||||
|
<ProjectReference Include="..\..\modules\saas\LINGYUN.Abp.Saas.EntityFrameworkCore\LINGYUN.Abp.Saas.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Folder Include="Migrations\" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,720 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(RealtimeMessageMigrationsDbContext))] |
||||
|
[Migration("20230110063428_Initial-Realtime-Message")] |
||||
|
partial class InitialRealtimeMessage |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("Age") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("AvatarUrl") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<DateTime?>("Birthday") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastOnlineTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("NickName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<int>("Sex") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Sign") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)"); |
||||
|
|
||||
|
b.Property<int>("State") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatCards", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<bool>("Black") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)"); |
||||
|
|
||||
|
b.Property<bool>("DontDisturb") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<Guid>("FrientId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("IsStatic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("RemarkName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<bool>("SpecialFocus") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<byte>("Status") |
||||
|
.HasColumnType("tinyint unsigned"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "FrientId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatFriends", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<bool>("AllowAddFriend") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowAnonymous") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowReceiveMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSendMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("RequireAddFriendValition") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatSettings", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("MessageId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid>("ReceiveUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("SendUserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<int>("Source") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<sbyte>("State") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "ReceiveUserId"); |
||||
|
|
||||
|
b.ToTable("AppUserMessages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("Address") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<Guid>("AdminUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowAnonymous") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSendMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("AvatarUrl") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<int>("MaxUserCount") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)"); |
||||
|
|
||||
|
b.Property<string>("Notice") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Tag") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "Name"); |
||||
|
|
||||
|
b.ToTable("AppChatGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid>("ShieldUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId"); |
||||
|
|
||||
|
b.ToTable("AppGroupChatBlacks", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<long>("MessageId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("SendUserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<int>("Source") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<sbyte>("State") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId"); |
||||
|
|
||||
|
b.ToTable("AppGroupMessages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsAdmin") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("NickName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<DateTime?>("SilenceEnd") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserGroupCards", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.Notification", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("ContentType") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int") |
||||
|
.HasDefaultValue(0); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<DateTime?>("ExpirationTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("NotificationId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("NotificationName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)"); |
||||
|
|
||||
|
b.Property<string>("NotificationTypeName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<sbyte>("Severity") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "NotificationName"); |
||||
|
|
||||
|
b.ToTable("AppNotifications", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionGroupRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSubscriptionToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppNotificationDefinitionGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSubscriptionToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<int>("ContentType") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int") |
||||
|
.HasDefaultValue(0); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<int>("NotificationLifetime") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<int>("NotificationType") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Providers") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("varchar(200)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppNotificationDefinitions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.UserNotification", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<long>("NotificationId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("ReadStatus") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "NotificationId") |
||||
|
.HasDatabaseName("IX_Tenant_User_Notification_Id"); |
||||
|
|
||||
|
b.ToTable("AppUserNotifications", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.UserSubscribe", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<string>("NotificationName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasDefaultValue("/"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "NotificationName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Tenant_User_Notification_Name"); |
||||
|
|
||||
|
b.ToTable("AppUserSubscribes", (string)null); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,483 @@ |
|||||
|
using System; |
||||
|
using Microsoft.EntityFrameworkCore.Metadata; |
||||
|
using Microsoft.EntityFrameworkCore.Migrations; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
public partial class InitialRealtimeMessage : Migration |
||||
|
{ |
||||
|
/// <inheritdoc />
|
||||
|
protected override void Up(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.AlterDatabase() |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppChatGroups", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
AdminUserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
GroupId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
Name = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Tag = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Address = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Notice = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
MaxUserCount = table.Column<int>(type: "int", nullable: false), |
||||
|
AllowAnonymous = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
AllowSendMessage = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
Description = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
AvatarUrl = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppChatGroups", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppGroupChatBlacks", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
GroupId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
ShieldUserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppGroupChatBlacks", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppGroupMessages", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
GroupId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
MessageId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
SendUserName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Content = table.Column<string>(type: "longtext", maxLength: 1048576, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Type = table.Column<int>(type: "int", nullable: false), |
||||
|
Source = table.Column<int>(type: "int", nullable: false), |
||||
|
State = table.Column<sbyte>(type: "tinyint", nullable: false) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppGroupMessages", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppNotificationDefinitionGroups", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
AllowSubscriptionToClients = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppNotificationDefinitionGroups", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppNotificationDefinitions", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
Name = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
GroupName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
DisplayName = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(255)", maxLength: 255, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
NotificationLifetime = table.Column<int>(type: "int", nullable: false), |
||||
|
NotificationType = table.Column<int>(type: "int", nullable: false), |
||||
|
ContentType = table.Column<int>(type: "int", nullable: false, defaultValue: 0), |
||||
|
Providers = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
AllowSubscriptionToClients = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppNotificationDefinitions", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppNotifications", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
Severity = table.Column<sbyte>(type: "tinyint", nullable: false), |
||||
|
Type = table.Column<int>(type: "int", nullable: false), |
||||
|
ContentType = table.Column<int>(type: "int", nullable: false, defaultValue: 0), |
||||
|
NotificationId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
NotificationName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
NotificationTypeName = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ExpirationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppNotifications", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserChatCards", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
UserName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Sex = table.Column<int>(type: "int", nullable: false), |
||||
|
Sign = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
NickName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
AvatarUrl = table.Column<string>(type: "varchar(512)", maxLength: 512, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Birthday = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
Age = table.Column<int>(type: "int", nullable: false), |
||||
|
LastOnlineTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
State = table.Column<int>(type: "int", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserChatCards", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserChatFriends", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
FrientId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
IsStatic = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
Black = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
DontDisturb = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
SpecialFocus = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
RemarkName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Description = table.Column<string>(type: "varchar(50)", maxLength: 50, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Status = table.Column<byte>(type: "tinyint unsigned", nullable: false), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserChatFriends", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserChatGroups", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
GroupId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserChatGroups", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserChatSettings", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
AllowAnonymous = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
AllowAddFriend = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
RequireAddFriendValition = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
AllowReceiveMessage = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
AllowSendMessage = table.Column<bool>(type: "tinyint(1)", nullable: false) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserChatSettings", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserGroupCards", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
NickName = table.Column<string>(type: "varchar(256)", maxLength: 256, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
IsAdmin = table.Column<bool>(type: "tinyint(1)", nullable: false), |
||||
|
SilenceEnd = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
LastModificationTime = table.Column<DateTime>(type: "datetime(6)", nullable: true), |
||||
|
LastModifierId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserGroupCards", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserMessages", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
ReceiveUserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
ExtraProperties = table.Column<string>(type: "longtext", nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
ConcurrencyStamp = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: true) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
CreatorId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
MessageId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
SendUserName = table.Column<string>(type: "varchar(64)", maxLength: 64, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Content = table.Column<string>(type: "longtext", maxLength: 1048576, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
Type = table.Column<int>(type: "int", nullable: false), |
||||
|
Source = table.Column<int>(type: "int", nullable: false), |
||||
|
State = table.Column<sbyte>(type: "tinyint", nullable: false) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserMessages", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserNotifications", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
NotificationId = table.Column<long>(type: "bigint", nullable: false), |
||||
|
ReadStatus = table.Column<int>(type: "int", nullable: false) |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserNotifications", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateTable( |
||||
|
name: "AppUserSubscribes", |
||||
|
columns: table => new |
||||
|
{ |
||||
|
Id = table.Column<long>(type: "bigint", nullable: false) |
||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), |
||||
|
UserId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"), |
||||
|
UserName = table.Column<string>(type: "varchar(128)", maxLength: 128, nullable: false, defaultValue: "/") |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"), |
||||
|
TenantId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"), |
||||
|
CreationTime = table.Column<DateTime>(type: "datetime(6)", nullable: false), |
||||
|
NotificationName = table.Column<string>(type: "varchar(100)", maxLength: 100, nullable: false) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4") |
||||
|
}, |
||||
|
constraints: table => |
||||
|
{ |
||||
|
table.PrimaryKey("PK_AppUserSubscribes", x => x.Id); |
||||
|
}) |
||||
|
.Annotation("MySql:CharSet", "utf8mb4"); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppChatGroups_TenantId_Name", |
||||
|
table: "AppChatGroups", |
||||
|
columns: new[] { "TenantId", "Name" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppGroupChatBlacks_TenantId_GroupId", |
||||
|
table: "AppGroupChatBlacks", |
||||
|
columns: new[] { "TenantId", "GroupId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppGroupMessages_TenantId_GroupId", |
||||
|
table: "AppGroupMessages", |
||||
|
columns: new[] { "TenantId", "GroupId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppNotifications_TenantId_NotificationName", |
||||
|
table: "AppNotifications", |
||||
|
columns: new[] { "TenantId", "NotificationName" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppUserChatCards_TenantId_UserId", |
||||
|
table: "AppUserChatCards", |
||||
|
columns: new[] { "TenantId", "UserId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppUserChatFriends_TenantId_UserId_FrientId", |
||||
|
table: "AppUserChatFriends", |
||||
|
columns: new[] { "TenantId", "UserId", "FrientId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppUserChatGroups_TenantId_GroupId_UserId", |
||||
|
table: "AppUserChatGroups", |
||||
|
columns: new[] { "TenantId", "GroupId", "UserId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppUserChatSettings_TenantId_UserId", |
||||
|
table: "AppUserChatSettings", |
||||
|
columns: new[] { "TenantId", "UserId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppUserGroupCards_TenantId_UserId", |
||||
|
table: "AppUserGroupCards", |
||||
|
columns: new[] { "TenantId", "UserId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_AppUserMessages_TenantId_ReceiveUserId", |
||||
|
table: "AppUserMessages", |
||||
|
columns: new[] { "TenantId", "ReceiveUserId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_Tenant_User_Notification_Id", |
||||
|
table: "AppUserNotifications", |
||||
|
columns: new[] { "TenantId", "UserId", "NotificationId" }); |
||||
|
|
||||
|
migrationBuilder.CreateIndex( |
||||
|
name: "IX_Tenant_User_Notification_Name", |
||||
|
table: "AppUserSubscribes", |
||||
|
columns: new[] { "TenantId", "UserId", "NotificationName" }, |
||||
|
unique: true); |
||||
|
} |
||||
|
|
||||
|
/// <inheritdoc />
|
||||
|
protected override void Down(MigrationBuilder migrationBuilder) |
||||
|
{ |
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppChatGroups"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppGroupChatBlacks"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppGroupMessages"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppNotificationDefinitionGroups"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppNotificationDefinitions"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppNotifications"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserChatCards"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserChatFriends"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserChatGroups"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserChatSettings"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserGroupCards"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserMessages"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserNotifications"); |
||||
|
|
||||
|
migrationBuilder.DropTable( |
||||
|
name: "AppUserSubscribes"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,717 @@ |
|||||
|
// <auto-generated />
|
||||
|
using System; |
||||
|
using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Infrastructure; |
||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
#nullable disable |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator.Migrations |
||||
|
{ |
||||
|
[DbContext(typeof(RealtimeMessageMigrationsDbContext))] |
||||
|
partial class RealtimeMessageMigrationsDbContextModelSnapshot : ModelSnapshot |
||||
|
{ |
||||
|
protected override void BuildModel(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
#pragma warning disable 612, 618
|
||||
|
modelBuilder |
||||
|
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) |
||||
|
.HasAnnotation("ProductVersion", "7.0.1") |
||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 64); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatCard", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("Age") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("AvatarUrl") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<DateTime?>("Birthday") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastOnlineTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("NickName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<int>("Sex") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Sign") |
||||
|
.HasMaxLength(30) |
||||
|
.HasColumnType("varchar(30)"); |
||||
|
|
||||
|
b.Property<int>("State") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatCards", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatFriend", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<bool>("Black") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(50) |
||||
|
.HasColumnType("varchar(50)"); |
||||
|
|
||||
|
b.Property<bool>("DontDisturb") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<Guid>("FrientId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("IsStatic") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("RemarkName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<bool>("SpecialFocus") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<byte>("Status") |
||||
|
.HasColumnType("tinyint unsigned"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "FrientId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatFriends", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserChatSetting", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<bool>("AllowAddFriend") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowAnonymous") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowReceiveMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSendMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("RequireAddFriendValition") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatSettings", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Chat.UserMessage", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("MessageId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid>("ReceiveUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("SendUserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<int>("Source") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<sbyte>("State") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "ReceiveUserId"); |
||||
|
|
||||
|
b.ToTable("AppUserMessages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.ChatGroup", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("Address") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<Guid>("AdminUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowAnonymous") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSendMessage") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("AvatarUrl") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<int>("MaxUserCount") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(20) |
||||
|
.HasColumnType("varchar(20)"); |
||||
|
|
||||
|
b.Property<string>("Notice") |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Tag") |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "Name"); |
||||
|
|
||||
|
b.ToTable("AppChatGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupChatBlack", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid>("ShieldUserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId"); |
||||
|
|
||||
|
b.ToTable("AppGroupChatBlacks", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.GroupMessage", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<string>("Content") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(1048576) |
||||
|
.HasColumnType("longtext"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<long>("MessageId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("SendUserName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<int>("Source") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<sbyte>("State") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId"); |
||||
|
|
||||
|
b.ToTable("AppGroupMessages", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserChatGroup", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<long>("GroupId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "GroupId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserChatGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.MessageService.Groups.UserGroupCard", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("ConcurrencyStamp") |
||||
|
.IsConcurrencyToken() |
||||
|
.HasMaxLength(40) |
||||
|
.HasColumnType("varchar(40)") |
||||
|
.HasColumnName("ConcurrencyStamp"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("CreatorId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("CreatorId"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<bool>("IsAdmin") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<DateTime?>("LastModificationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("LastModificationTime"); |
||||
|
|
||||
|
b.Property<Guid?>("LastModifierId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("LastModifierId"); |
||||
|
|
||||
|
b.Property<string>("NickName") |
||||
|
.HasMaxLength(256) |
||||
|
.HasColumnType("varchar(256)"); |
||||
|
|
||||
|
b.Property<DateTime?>("SilenceEnd") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId"); |
||||
|
|
||||
|
b.ToTable("AppUserGroupCards", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.Notification", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("ContentType") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int") |
||||
|
.HasDefaultValue(0); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<DateTime?>("ExpirationTime") |
||||
|
.HasColumnType("datetime(6)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<long>("NotificationId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<string>("NotificationName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)"); |
||||
|
|
||||
|
b.Property<string>("NotificationTypeName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(512) |
||||
|
.HasColumnType("varchar(512)"); |
||||
|
|
||||
|
b.Property<sbyte>("Severity") |
||||
|
.HasColumnType("tinyint"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<int>("Type") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "NotificationName"); |
||||
|
|
||||
|
b.ToTable("AppNotifications", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionGroupRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSubscriptionToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppNotificationDefinitionGroups", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.NotificationDefinitionRecord", b => |
||||
|
{ |
||||
|
b.Property<Guid>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<bool>("AllowSubscriptionToClients") |
||||
|
.HasColumnType("tinyint(1)"); |
||||
|
|
||||
|
b.Property<int>("ContentType") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("int") |
||||
|
.HasDefaultValue(0); |
||||
|
|
||||
|
b.Property<string>("Description") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("DisplayName") |
||||
|
.HasMaxLength(255) |
||||
|
.HasColumnType("varchar(255)"); |
||||
|
|
||||
|
b.Property<string>("ExtraProperties") |
||||
|
.HasColumnType("longtext") |
||||
|
.HasColumnName("ExtraProperties"); |
||||
|
|
||||
|
b.Property<string>("GroupName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<string>("Name") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(64) |
||||
|
.HasColumnType("varchar(64)"); |
||||
|
|
||||
|
b.Property<int>("NotificationLifetime") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<int>("NotificationType") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<string>("Providers") |
||||
|
.HasMaxLength(200) |
||||
|
.HasColumnType("varchar(200)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.ToTable("AppNotificationDefinitions", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.UserNotification", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<long>("NotificationId") |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<int>("ReadStatus") |
||||
|
.HasColumnType("int"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "NotificationId") |
||||
|
.HasDatabaseName("IX_Tenant_User_Notification_Id"); |
||||
|
|
||||
|
b.ToTable("AppUserNotifications", (string)null); |
||||
|
}); |
||||
|
|
||||
|
modelBuilder.Entity("LINGYUN.Abp.Notifications.UserSubscribe", b => |
||||
|
{ |
||||
|
b.Property<long>("Id") |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasColumnType("bigint"); |
||||
|
|
||||
|
b.Property<DateTime>("CreationTime") |
||||
|
.HasColumnType("datetime(6)") |
||||
|
.HasColumnName("CreationTime"); |
||||
|
|
||||
|
b.Property<string>("NotificationName") |
||||
|
.IsRequired() |
||||
|
.HasMaxLength(100) |
||||
|
.HasColumnType("varchar(100)"); |
||||
|
|
||||
|
b.Property<Guid?>("TenantId") |
||||
|
.HasColumnType("char(36)") |
||||
|
.HasColumnName("TenantId"); |
||||
|
|
||||
|
b.Property<Guid>("UserId") |
||||
|
.HasColumnType("char(36)"); |
||||
|
|
||||
|
b.Property<string>("UserName") |
||||
|
.IsRequired() |
||||
|
.ValueGeneratedOnAdd() |
||||
|
.HasMaxLength(128) |
||||
|
.HasColumnType("varchar(128)") |
||||
|
.HasDefaultValue("/"); |
||||
|
|
||||
|
b.HasKey("Id"); |
||||
|
|
||||
|
b.HasIndex("TenantId", "UserId", "NotificationName") |
||||
|
.IsUnique() |
||||
|
.HasDatabaseName("IX_Tenant_User_Notification_Name"); |
||||
|
|
||||
|
b.ToTable("AppUserSubscribes", (string)null); |
||||
|
}); |
||||
|
#pragma warning restore 612, 618
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,40 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator; |
||||
|
|
||||
|
public class Program |
||||
|
{ |
||||
|
public async static Task Main(string[] args) |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("LY.MicroService.RealtimeMessage.DbMigrator", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("LY.MicroService.RealtimeMessage.DbMigrator", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.Console() |
||||
|
.WriteTo.File("Logs/migrations.txt") |
||||
|
.CreateLogger(); |
||||
|
|
||||
|
await CreateHostBuilder(args).RunConsoleAsync(); |
||||
|
} |
||||
|
|
||||
|
public static IHostBuilder CreateHostBuilder(string[] args) |
||||
|
{ |
||||
|
return Host.CreateDefaultBuilder(args) |
||||
|
.AddAppSettingsSecretsJson() |
||||
|
.ConfigureLogging((context, logging) => logging.ClearProviders()) |
||||
|
.ConfigureServices((hostContext, services) => |
||||
|
{ |
||||
|
services.AddHostedService<RealtimeMessageDbMigratorHostedService>(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
{ |
||||
|
"profiles": { |
||||
|
"LY.MicroService.RealtimeMessage.DbMigrator": { |
||||
|
"commandName": "Project", |
||||
|
"dotnetRunMessages": true, |
||||
|
"environmentVariables": { |
||||
|
"ASPNETCORE_ENVIRONMENT": "Development" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Configuration; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Microsoft.Extensions.Hosting; |
||||
|
using Serilog; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Data; |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator; |
||||
|
|
||||
|
public class RealtimeMessageDbMigratorHostedService : IHostedService |
||||
|
{ |
||||
|
private readonly IHostApplicationLifetime _hostApplicationLifetime; |
||||
|
private readonly IConfiguration _configuration; |
||||
|
|
||||
|
public RealtimeMessageDbMigratorHostedService( |
||||
|
IHostApplicationLifetime hostApplicationLifetime, |
||||
|
IConfiguration configuration) |
||||
|
{ |
||||
|
_hostApplicationLifetime = hostApplicationLifetime; |
||||
|
_configuration = configuration; |
||||
|
} |
||||
|
|
||||
|
public async Task StartAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
using var application = await AbpApplicationFactory |
||||
|
.CreateAsync<RealtimeMessageDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.Services.ReplaceConfiguration(_configuration); |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
options.AddDataMigrationEnvironment(); |
||||
|
}); |
||||
|
await application.InitializeAsync(); |
||||
|
|
||||
|
await application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<RealtimeMessageDbMigrationService>() |
||||
|
.MigrateAsync(); |
||||
|
|
||||
|
await application.ShutdownAsync(); |
||||
|
|
||||
|
_hostApplicationLifetime.StopApplication(); |
||||
|
} |
||||
|
|
||||
|
public Task StopAsync(CancellationToken cancellationToken) |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
@ -0,0 +1,18 @@ |
|||||
|
using LY.MicroService.RealtimeMessage.DbMigrator.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator; |
||||
|
public partial class RealtimeMessageDbMigratorModule |
||||
|
{ |
||||
|
private void ConfigureDbContext(IServiceCollection services) |
||||
|
{ |
||||
|
services.AddAbpDbContext<RealtimeMessageMigrationsDbContext>(); |
||||
|
|
||||
|
// 配置Ef
|
||||
|
Configure<AbpDbContextOptions>(options => |
||||
|
{ |
||||
|
options.UseMySQL(); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,29 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.MessageService.EntityFrameworkCore; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.FeatureManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.EntityFrameworkCore; |
||||
|
using Volo.Abp.SettingManagement.EntityFrameworkCore; |
||||
|
using LINGYUN.Abp.Notifications.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.RealtimeMessage.DbMigrator; |
||||
|
|
||||
|
[DependsOn( |
||||
|
typeof(AbpSaasEntityFrameworkCoreModule), |
||||
|
typeof(AbpSettingManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpPermissionManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpFeatureManagementEntityFrameworkCoreModule), |
||||
|
typeof(AbpNotificationsEntityFrameworkCoreModule), |
||||
|
typeof(AbpMessageServiceEntityFrameworkCoreModule), |
||||
|
typeof(AbpDataDbMigratorModule), |
||||
|
typeof(AbpAutofacModule) |
||||
|
)] |
||||
|
public partial class RealtimeMessageDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
ConfigureDbContext(context.Services); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp; |
||||
|
using LINGYUN.Abp; |
||||
@ -0,0 +1,81 @@ |
|||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", |
||||
|
"Notifications": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", |
||||
|
"MessageService": "Server=127.0.0.1;Database=Messages-v70;User Id=root;Password=123456", |
||||
|
"AbpSaas": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpSettingManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpPermissionManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456", |
||||
|
"AbpLocalizationManagement": "Server=127.0.0.1;Database=Platform-v70;User Id=root;Password=123456" |
||||
|
}, |
||||
|
"StringEncryption": { |
||||
|
"DefaultPassPhrase": "s46c5q55nxpeS8Ra", |
||||
|
"InitVectorBytes": "s83ng0abvd02js84", |
||||
|
"DefaultSalt": "sf&5)s3#" |
||||
|
}, |
||||
|
"Serilog": { |
||||
|
"MinimumLevel": { |
||||
|
"Default": "Information", |
||||
|
"Override": { |
||||
|
"System": "Warning", |
||||
|
"Microsoft": "Warning", |
||||
|
"DotNetCore": "Information" |
||||
|
} |
||||
|
}, |
||||
|
"Enrich": [ "FromLogContext", "WithProcessId", "WithThreadId", "WithEnvironmentName", "WithMachineName", "WithApplicationName", "WithUniqueId" ], |
||||
|
"WriteTo": [ |
||||
|
{ |
||||
|
"Name": "Console", |
||||
|
"Args": { |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Debug-.log", |
||||
|
"restrictedToMinimumLevel": "Debug", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Info-.log", |
||||
|
"restrictedToMinimumLevel": "Information", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Warn-.log", |
||||
|
"restrictedToMinimumLevel": "Warning", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Error-.log", |
||||
|
"restrictedToMinimumLevel": "Error", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
}, |
||||
|
{ |
||||
|
"Name": "File", |
||||
|
"Args": { |
||||
|
"path": "Logs/Fatal-.log", |
||||
|
"restrictedToMinimumLevel": "Fatal", |
||||
|
"rollingInterval": "Day", |
||||
|
"outputTemplate": "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] [{SourceContext}] [{ProcessId}] [{ThreadId}] - {Message:lj}{NewLine}{Exception}" |
||||
|
} |
||||
|
} |
||||
|
] |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,216 @@ |
|||||
|
using LINGYUN.Abp.Data.DbMigrator; |
||||
|
using LINGYUN.Abp.Saas.Tenants; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using System.Diagnostics; |
||||
|
using System.Runtime.InteropServices; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.MultiTenancy; |
||||
|
|
||||
|
namespace LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
public class TaskManagementDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<TaskManagementDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IDbSchemaMigrator _dbSchemaMigrator; |
||||
|
private readonly ITenantRepository _tenantRepository; |
||||
|
private readonly ICurrentTenant _currentTenant; |
||||
|
|
||||
|
public TaskManagementDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IDbSchemaMigrator dbSchemaMigrator, |
||||
|
ITenantRepository tenantRepository, |
||||
|
ICurrentTenant currentTenant) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
_tenantRepository = tenantRepository; |
||||
|
_currentTenant = currentTenant; |
||||
|
|
||||
|
Logger = NullLogger<TaskManagementDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
var initialMigrationAdded = AddInitialMigrationIfNotExist(); |
||||
|
|
||||
|
if (initialMigrationAdded) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
await MigrateDatabaseSchemaAsync(); |
||||
|
await SeedDataAsync(); |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed host database migrations."); |
||||
|
|
||||
|
var tenants = await _tenantRepository.GetListAsync(includeDetails: true); |
||||
|
|
||||
|
var migratedDatabaseSchemas = new HashSet<string>(); |
||||
|
foreach (var tenant in tenants) |
||||
|
{ |
||||
|
using (_currentTenant.Change(tenant.Id)) |
||||
|
{ |
||||
|
if (tenant.ConnectionStrings.Any()) |
||||
|
{ |
||||
|
var tenantConnectionStrings = tenant.ConnectionStrings |
||||
|
.Select(x => x.Value) |
||||
|
.ToList(); |
||||
|
|
||||
|
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings)) |
||||
|
{ |
||||
|
await MigrateDatabaseSchemaAsync(tenant); |
||||
|
|
||||
|
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
await SeedDataAsync(tenant); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations."); |
||||
|
} |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed all database migrations."); |
||||
|
Logger.LogInformation("You can safely end this process..."); |
||||
|
} |
||||
|
|
||||
|
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database..."); |
||||
|
// 迁移租户数据
|
||||
|
await _dbSchemaMigrator.MigrateAsync<TaskManagementMigrationsDbContext>( |
||||
|
(connectionString, builder) => |
||||
|
{ |
||||
|
builder.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
|
return new TaskManagementMigrationsDbContext(builder.Options); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private async Task SeedDataAsync(Tenant? tenant = null) |
||||
|
{ |
||||
|
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed..."); |
||||
|
|
||||
|
await _dataSeeder.SeedAsync(tenant?.Id); |
||||
|
} |
||||
|
|
||||
|
private bool AddInitialMigrationIfNotExist() |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
if (!DbMigrationsProjectExists()) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
if (!MigrationsFolderExists()) |
||||
|
{ |
||||
|
AddInitialMigration(); |
||||
|
return true; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message); |
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private bool DbMigrationsProjectExists() |
||||
|
{ |
||||
|
return Directory.Exists(GetEntityFrameworkCoreProjectFolderPath()); |
||||
|
} |
||||
|
|
||||
|
private bool MigrationsFolderExists() |
||||
|
{ |
||||
|
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath(); |
||||
|
|
||||
|
return Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations")); |
||||
|
} |
||||
|
|
||||
|
private void AddInitialMigration() |
||||
|
{ |
||||
|
Logger.LogInformation("Creating initial migration..."); |
||||
|
|
||||
|
string argumentPrefix; |
||||
|
string fileName; |
||||
|
|
||||
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
||||
|
{ |
||||
|
argumentPrefix = "-c"; |
||||
|
fileName = "/bin/bash"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
argumentPrefix = "/C"; |
||||
|
fileName = "cmd.exe"; |
||||
|
} |
||||
|
|
||||
|
var procStartInfo = new ProcessStartInfo(fileName, |
||||
|
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\" --nolayers\"" |
||||
|
); |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
Process.Start(procStartInfo); |
||||
|
} |
||||
|
catch (Exception) |
||||
|
{ |
||||
|
throw new Exception("Couldn't run ABP CLI..."); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private string GetEntityFrameworkCoreProjectFolderPath() |
||||
|
{ |
||||
|
var slnDirectoryPath = GetSolutionDirectoryPath(); |
||||
|
|
||||
|
if (slnDirectoryPath == null) |
||||
|
{ |
||||
|
throw new Exception("Solution folder not found!"); |
||||
|
} |
||||
|
|
||||
|
return Path.Combine(slnDirectoryPath, "LY.MicroService.TaskManagement.DbMigrator"); |
||||
|
} |
||||
|
|
||||
|
private string? GetSolutionDirectoryPath() |
||||
|
{ |
||||
|
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); |
||||
|
|
||||
|
while (Directory.GetParent(currentDirectory.FullName) != null) |
||||
|
{ |
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
|
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
|
||||
|
// parent host
|
||||
|
currentDirectory = Directory.GetParent(currentDirectory.FullName); |
||||
|
if (Directory.GetFiles(currentDirectory!.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null) |
||||
|
{ |
||||
|
return currentDirectory.FullName; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return null; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using LINGYUN.Abp.TaskManagement.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
|
[ConnectionStringName("TaskManagementDbMigrator")] |
||||
|
public class TaskManagementMigrationsDbContext : AbpDbContext<TaskManagementMigrationsDbContext> |
||||
|
{ |
||||
|
public TaskManagementMigrationsDbContext(DbContextOptions<TaskManagementMigrationsDbContext> options) |
||||
|
: base(options) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
protected override void OnModelCreating(ModelBuilder modelBuilder) |
||||
|
{ |
||||
|
base.OnModelCreating(modelBuilder); |
||||
|
|
||||
|
modelBuilder.ConfigureTaskManagement(); |
||||
|
} |
||||
|
} |
||||
@ -1,21 +1,20 @@ |
|||||
using Microsoft.EntityFrameworkCore; |
using Microsoft.EntityFrameworkCore; |
||||
using Microsoft.EntityFrameworkCore.Design; |
using Microsoft.EntityFrameworkCore.Design; |
||||
using Microsoft.Extensions.Configuration; |
using Microsoft.Extensions.Configuration; |
||||
using System.IO; |
|
||||
|
|
||||
namespace LY.MicroService.TaskManagement.EntityFrameworkCore; |
namespace LY.MicroService.TaskManagement.DbMigrator.EntityFrameworkCore; |
||||
|
|
||||
public class TaskManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory<TaskManagementMigrationsDbContext> |
public class TaskManagementMigrationsDbContextFactory : IDesignTimeDbContextFactory<TaskManagementMigrationsDbContext> |
||||
{ |
{ |
||||
public TaskManagementMigrationsDbContext CreateDbContext(string[] args) |
public TaskManagementMigrationsDbContext CreateDbContext(string[] args) |
||||
{ |
{ |
||||
var configuration = BuildConfiguration(); |
var configuration = BuildConfiguration(); |
||||
var connectionString = configuration.GetConnectionString("TaskManagement"); |
var connectionString = configuration.GetConnectionString("Default"); |
||||
|
|
||||
var builder = new DbContextOptionsBuilder<TaskManagementMigrationsDbContext>() |
var builder = new DbContextOptionsBuilder<TaskManagementMigrationsDbContext>() |
||||
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
.UseMySql(connectionString, ServerVersion.AutoDetect(connectionString)); |
||||
|
|
||||
return new TaskManagementMigrationsDbContext(builder.Options); |
return new TaskManagementMigrationsDbContext(builder!.Options); |
||||
} |
} |
||||
|
|
||||
private static IConfigurationRoot BuildConfiguration() |
private static IConfigurationRoot BuildConfiguration() |
||||
@ -0,0 +1,55 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>net7.0</TargetFramework> |
||||
|
<ImplicitUsings>enable</ImplicitUsings> |
||||
|
<Nullable>enable</Nullable> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="$(SerilogExtensionsLoggingPackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="$(SerilogSinksFilePackageVersion)" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="$(SerilogSinksConsolePackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.Extensions.Hosting" Version="$(MicrosoftPackageVersion)" /> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="$(MicrosoftPackageVersion)"> |
||||
|
<PrivateAssets>all</PrivateAssets> |
||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
||||
|
</PackageReference> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.EntityFrameworkCore.MySql" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="$(VoloAbpPackageVersion)" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Compile Remove="Logs\**" /> |
||||
|
<Content Remove="Logs\**" /> |
||||
|
<EmbeddedResource Remove="Logs\**" /> |
||||
|
<None Remove="Logs\**" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> |
||||
|
<ExcludeFromSingleFile>true</ExcludeFromSingleFile> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\..\modules\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.TaskManagement.EntityFrameworkCore\LINGYUN.Abp.TaskManagement.EntityFrameworkCore.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Folder Include="Migrations\" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue