Browse Source

Merge pull request #1526 from colinin/fix-unique-index-by-resource-permission

fix: Fix the error of the unique index for resource permission
dev
yx lin 2 weeks ago
committed by GitHub
parent
commit
66ea06254e
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService.EntityFrameworkCore/Migrations/20260403034826_Upgrade-Abp-Framework-To-10-2-0.cs
  2. 14
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20260421022905_Upgrade-Abp-Framework-To-10-2-0.cs
  3. 6179
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20260626034342_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.Designer.cs
  4. 111
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20260626034342_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.cs
  5. 10
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/SingleMigrationsDbContextModelSnapshot.cs
  6. 9
      aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore/SingleMigrationsDbContext.cs
  7. 10
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminMigrationsDbContext.cs
  8. 4
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/LY.MicroService.BackendAdmin.EntityFrameworkCore.csproj
  9. 1102
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20260626032421_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.Designer.cs
  10. 86
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20260626032421_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.cs
  11. 10
      aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs
  12. 3
      aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.EntityFrameworkCore/LINGYUN/Abp/PermissionManagement/EntityFrameworkCore/AbpPermissionManagementEntityFrameworkCoreModule.cs

2
aspnet-core/aspire/LINGYUN.Abp.MicroService.AdminService.EntityFrameworkCore/Migrations/20260403034826_Upgrade-Abp-Framework-To-10-2-0.cs

@ -65,7 +65,7 @@ namespace LINGYUN.Abp.MicroService.AdminService.Migrations
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Reso~", name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Reso~",
table: "AbpResourcePermissionGrants", table: "AbpResourcePermissionGrants",
columns: new[] { "TenantId", "ResourceName", "ResourceKey", "ProviderName", "ProviderKey" }, columns: new[] { "TenantId", "Name", "ResourceName", "ResourceKey", "ProviderName", "ProviderKey" },
unique: true); unique: true);
} }

14
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20260421022905_Upgrade-Abp-Framework-To-10-2-0.cs

@ -497,20 +497,6 @@ namespace LY.MicroService.Applications.Single.EntityFrameworkCore.MySql.Migratio
table: "AbpBlobs", table: "AbpBlobs",
columns: new[] { "TenantId", "ContainerId", "FullName" }); columns: new[] { "TenantId", "ContainerId", "FullName" });
// TODO: Specified key was too long; max key length is 3072 bytes
// Fix: Remove Name
// TenantId: 36 × 4 = 144
// Name: 128 × 4 = 512
// ResourceName:256 × 4 = 1024
// ResourceKey: 256 × 4 = 1024
// ProviderName:64 × 4 = 256
// ProviderKey: 64 × 4 = 256
// = 3216
//migrationBuilder.CreateIndex(
// name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
// table: "AbpResourcePermissionGrants",
// columns: new[] { "TenantId", "Name", "ResourceName", "ResourceKey", "ProviderName", "ProviderKey" },
// unique: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~", name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants", table: "AbpResourcePermissionGrants",

6179
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20260626034342_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.Designer.cs

File diff suppressed because it is too large

111
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/20260626034342_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.cs

@ -0,0 +1,111 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LY.MicroService.Applications.Single.EntityFrameworkCore.MySql.Migrations
{
/// <inheritdoc />
public partial class FixMySqlIndexKeyTooLangForResourcePermissionGrant : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants");
migrationBuilder.AlterColumn<Guid>(
name: "EntityId",
table: "Demo_BooksAuths",
type: "char(64)",
maxLength: 64,
nullable: false,
collation: "ascii_general_ci",
oldClrType: typeof(string),
oldType: "char(64)",
oldMaxLength: 64)
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ResourceName",
table: "AbpResourcePermissionGrants",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ResourceKey",
table: "AbpResourcePermissionGrants",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants",
columns: new[] { "TenantId", "Name", "ResourceName", "ResourceKey", "ProviderName", "ProviderKey" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants");
migrationBuilder.AlterColumn<string>(
name: "EntityId",
table: "Demo_BooksAuths",
type: "char(64)",
maxLength: 64,
nullable: false,
oldClrType: typeof(Guid),
oldType: "char(64)",
oldMaxLength: 64)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AlterColumn<string>(
name: "ResourceName",
table: "AbpResourcePermissionGrants",
type: "varchar(256)",
maxLength: 256,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ResourceKey",
table: "AbpResourcePermissionGrants",
type: "varchar(256)",
maxLength: 256,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants",
columns: new[] { "TenantId", "ResourceName", "ResourceKey", "ProviderName", "ProviderKey" },
unique: true);
}
}
}

10
aspnet-core/migrations/LY.MicroService.Applications.Single.EntityFrameworkCore.MySql/Migrations/SingleMigrationsDbContextModelSnapshot.cs

@ -19,7 +19,7 @@ namespace LY.MicroService.Applications.Single.EntityFrameworkCore.MySql.Migratio
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("ProductVersion", "10.0.3") .HasAnnotation("ProductVersion", "10.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 64); .HasAnnotation("Relational:MaxIdentifierLength", 64);
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
@ -5624,13 +5624,13 @@ namespace LY.MicroService.Applications.Single.EntityFrameworkCore.MySql.Migratio
b.Property<string>("ResourceKey") b.Property<string>("ResourceKey")
.IsRequired() .IsRequired()
.HasMaxLength(256) .HasMaxLength(128)
.HasColumnType("varchar(256)"); .HasColumnType("varchar(128)");
b.Property<string>("ResourceName") b.Property<string>("ResourceName")
.IsRequired() .IsRequired()
.HasMaxLength(256) .HasMaxLength(128)
.HasColumnType("varchar(256)"); .HasColumnType("varchar(128)");
b.Property<Guid?>("TenantId") b.Property<Guid?>("TenantId")
.HasColumnType("char(36)") .HasColumnType("char(36)")

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

@ -287,5 +287,14 @@ public class SingleMigrationsDbContext :
modelBuilder.ConfigureBlobManagement(); modelBuilder.ConfigureBlobManagement();
modelBuilder.ConfigureIdentityUserInactive(); modelBuilder.ConfigureIdentityUserInactive();
modelBuilder.Entity<ResourcePermissionGrant>(b =>
{
var maxResourceNameLength = modelBuilder.IsUsingMySQL() ? 128 : PermissionGrantConsts.MaxResourceNameLength;
var maxResourceKeyLength = modelBuilder.IsUsingMySQL() ? 128 : PermissionGrantConsts.MaxResourceKeyLength;
b.Property(x => x.ResourceName).HasMaxLength(maxResourceNameLength).IsRequired();
b.Property(x => x.ResourceKey).HasMaxLength(maxResourceKeyLength).IsRequired();
});
} }
} }

10
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/BackendAdminMigrationsDbContext.cs

@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.FeatureManagement.EntityFrameworkCore; using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement.EntityFrameworkCore; using Volo.Abp.SettingManagement.EntityFrameworkCore;
@ -29,5 +30,14 @@ public class BackendAdminMigrationsDbContext : AbpDbContext<BackendAdminMigratio
modelBuilder.ConfigureSettingManagement(); modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigurePermissionManagement(); modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureDataProtectionManagement(); modelBuilder.ConfigureDataProtectionManagement();
modelBuilder.Entity<ResourcePermissionGrant>(b =>
{
var maxResourceNameLength = modelBuilder.IsUsingMySQL() ? 128 : PermissionGrantConsts.MaxResourceNameLength;
var maxResourceKeyLength = modelBuilder.IsUsingMySQL() ? 128 : PermissionGrantConsts.MaxResourceKeyLength;
b.Property(x => x.ResourceName).HasMaxLength(maxResourceNameLength).IsRequired();
b.Property(x => x.ResourceKey).HasMaxLength(maxResourceKeyLength).IsRequired();
});
} }
} }

4
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/LY.MicroService.BackendAdmin.EntityFrameworkCore.csproj

@ -14,6 +14,10 @@
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" /> <PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" />
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" /> <PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" />
</ItemGroup> </ItemGroup>

1102
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20260626032421_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.Designer.cs

File diff suppressed because it is too large

86
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/20260626032421_Fix-MySql-Index-Key-Too-Lang-For-Resource-Permission-Grant.cs

@ -0,0 +1,86 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations
{
/// <inheritdoc />
public partial class FixMySqlIndexKeyTooLangForResourcePermissionGrant : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants");
migrationBuilder.AlterColumn<string>(
name: "ResourceName",
table: "AbpResourcePermissionGrants",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ResourceKey",
table: "AbpResourcePermissionGrants",
type: "varchar(128)",
maxLength: 128,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(256)",
oldMaxLength: 256)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants",
columns: new[] { "TenantId", "Name", "ResourceName", "ResourceKey", "ProviderName", "ProviderKey" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants");
migrationBuilder.AlterColumn<string>(
name: "ResourceName",
table: "AbpResourcePermissionGrants",
type: "varchar(256)",
maxLength: 256,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "ResourceKey",
table: "AbpResourcePermissionGrants",
type: "varchar(256)",
maxLength: 256,
nullable: false,
oldClrType: typeof(string),
oldType: "varchar(128)",
oldMaxLength: 128)
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_AbpResourcePermissionGrants_TenantId_Name_ResourceName_Resou~",
table: "AbpResourcePermissionGrants",
columns: new[] { "TenantId", "ResourceName", "ResourceKey", "ProviderName", "ProviderKey" },
unique: true);
}
}
}

10
aspnet-core/migrations/LY.MicroService.BackendAdmin.EntityFrameworkCore/Migrations/BackendAdminMigrationsDbContextModelSnapshot.cs

@ -19,7 +19,7 @@ namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql) .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.MySql)
.HasAnnotation("ProductVersion", "10.0.3") .HasAnnotation("ProductVersion", "10.0.7")
.HasAnnotation("Relational:MaxIdentifierLength", 64); .HasAnnotation("Relational:MaxIdentifierLength", 64);
MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder); MySqlModelBuilderExtensions.AutoIncrementColumns(modelBuilder);
@ -916,13 +916,13 @@ namespace LY.MicroService.BackendAdmin.EntityFrameworkCore.Migrations
b.Property<string>("ResourceKey") b.Property<string>("ResourceKey")
.IsRequired() .IsRequired()
.HasMaxLength(256) .HasMaxLength(128)
.HasColumnType("varchar(256)"); .HasColumnType("varchar(128)");
b.Property<string>("ResourceName") b.Property<string>("ResourceName")
.IsRequired() .IsRequired()
.HasMaxLength(256) .HasMaxLength(128)
.HasColumnType("varchar(256)"); .HasColumnType("varchar(128)");
b.Property<Guid?>("TenantId") b.Property<Guid?>("TenantId")
.HasColumnType("char(36)") .HasColumnType("char(36)")

3
aspnet-core/modules/permissions-management/LINGYUN.Abp.PermissionManagement.EntityFrameworkCore/LINGYUN/Abp/PermissionManagement/EntityFrameworkCore/AbpPermissionManagementEntityFrameworkCoreModule.cs

@ -1,5 +1,6 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore; using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using VoloAbpPermissionManagementEntityFrameworkCoreModule = Volo.Abp.PermissionManagement.EntityFrameworkCore.AbpPermissionManagementEntityFrameworkCoreModule; using VoloAbpPermissionManagementEntityFrameworkCoreModule = Volo.Abp.PermissionManagement.EntityFrameworkCore.AbpPermissionManagementEntityFrameworkCoreModule;
@ -16,7 +17,7 @@ public class AbpPermissionManagementEntityFrameworkCoreModule : AbpModule
{ {
options.AddDefaultRepositories<IPermissionManagementDbContext>(); options.AddDefaultRepositories<IPermissionManagementDbContext>();
options.AddRepository<Volo.Abp.PermissionManagement.PermissionGrant, EfCorePermissionGrantRepository>(); options.AddRepository<PermissionGrant, EfCorePermissionGrantRepository>();
}); });
} }
} }

Loading…
Cancel
Save