Skip to content

Commit 7649ccb

Browse files
committed
Add indexes for SCIMRepresentationAttribute
1 parent f8ee73f commit 7649ccb

11 files changed

Lines changed: 1697 additions & 7 deletions

src/Scim/SimpleIdServer.Scim.MySQLMigrations/Migrations/20240706101356_AddIndexesForRepresentationAttribute.Designer.cs

Lines changed: 491 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
using Microsoft.EntityFrameworkCore.Metadata;
2+
using Microsoft.EntityFrameworkCore.Migrations;
3+
4+
#nullable disable
5+
6+
namespace SimpleIdServer.Scim.MySQLMigrations.Migrations
7+
{
8+
/// <inheritdoc />
9+
public partial class AddIndexesForRepresentationAttribute : Migration
10+
{
11+
/// <inheritdoc />
12+
protected override void Up(MigrationBuilder migrationBuilder)
13+
{
14+
migrationBuilder.AlterColumn<string>(
15+
name: "FullPath",
16+
schema: "dbo",
17+
table: "SCIMRepresentationAttributeLst",
18+
type: "varchar(512)",
19+
maxLength: 512,
20+
nullable: true,
21+
oldClrType: typeof(string),
22+
oldType: "longtext",
23+
oldNullable: true)
24+
.Annotation("MySql:CharSet", "utf8mb4")
25+
.OldAnnotation("MySql:CharSet", "utf8mb4");
26+
27+
migrationBuilder.CreateIndex(
28+
name: "IX_SCIMRepresentationAttributeLst_FullPath",
29+
schema: "dbo",
30+
table: "SCIMRepresentationAttributeLst",
31+
column: "FullPath");
32+
33+
migrationBuilder.CreateIndex(
34+
name: "IX_SCIMRepresentationAttributeLst_ValueString",
35+
schema: "dbo",
36+
table: "SCIMRepresentationAttributeLst",
37+
column: "ValueString");
38+
}
39+
40+
/// <inheritdoc />
41+
protected override void Down(MigrationBuilder migrationBuilder)
42+
{
43+
migrationBuilder.DropIndex(
44+
name: "IX_SCIMRepresentationAttributeLst_FullPath",
45+
schema: "dbo",
46+
table: "SCIMRepresentationAttributeLst");
47+
48+
migrationBuilder.DropIndex(
49+
name: "IX_SCIMRepresentationAttributeLst_ValueString",
50+
schema: "dbo",
51+
table: "SCIMRepresentationAttributeLst");
52+
53+
migrationBuilder.AlterColumn<string>(
54+
name: "FullPath",
55+
schema: "dbo",
56+
table: "SCIMRepresentationAttributeLst",
57+
type: "longtext",
58+
nullable: true,
59+
oldClrType: typeof(string),
60+
oldType: "varchar(512)",
61+
oldMaxLength: 512,
62+
oldNullable: true)
63+
.Annotation("MySql:CharSet", "utf8mb4")
64+
.OldAnnotation("MySql:CharSet", "utf8mb4");
65+
}
66+
}
67+
}

src/Scim/SimpleIdServer.Scim.MySQLMigrations/Migrations/SCIMDbContextModelSnapshot.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System;
33
using Microsoft.EntityFrameworkCore;
44
using Microsoft.EntityFrameworkCore.Infrastructure;
5+
using Microsoft.EntityFrameworkCore.Metadata;
56
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
67
using SimpleIdServer.Scim.Persistence.EF;
78

@@ -17,7 +18,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1718
#pragma warning disable 612, 618
1819
modelBuilder
1920
.HasDefaultSchema("dbo")
20-
.HasAnnotation("ProductVersion", "7.0.18")
21+
.HasAnnotation("ProductVersion", "8.0.4")
2122
.HasAnnotation("Relational:MaxIdentifierLength", 64);
2223

2324
modelBuilder.Entity("SCIMRepresentationSCIMSchema", b =>
@@ -212,7 +213,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
212213
.HasColumnType("longtext");
213214

214215
b.Property<string>("FullPath")
215-
.HasColumnType("longtext");
216+
.HasMaxLength(512)
217+
.HasColumnType("varchar(512)");
216218

217219
b.Property<bool>("IsComputed")
218220
.HasColumnType("tinyint(1)");
@@ -256,12 +258,16 @@ protected override void BuildModel(ModelBuilder modelBuilder)
256258

257259
b.HasKey("Id");
258260

261+
b.HasIndex("FullPath");
262+
259263
b.HasIndex("ParentAttributeId");
260264

261265
b.HasIndex("RepresentationId");
262266

263267
b.HasIndex("SchemaAttributeId");
264268

269+
b.HasIndex("ValueString");
270+
265271
b.ToTable("SCIMRepresentationAttributeLst", "dbo");
266272
});
267273

src/Scim/SimpleIdServer.Scim.Persistence.EF/Configurations/SCIMRepresentationAttributeConfiguration.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ public void Configure(EntityTypeBuilder<SCIMRepresentationAttribute> builder)
1414
builder.HasOne(a => a.SchemaAttribute).WithMany().HasForeignKey(a => a.SchemaAttributeId).OnDelete(DeleteBehavior.Cascade);
1515
builder.HasMany(a => a.Children).WithOne().HasForeignKey("ParentAttributeId");
1616
builder.Ignore(a => a.CachedChildren);
17+
builder.Property(a => a.FullPath).HasMaxLength(512);
1718
builder.Property(a => a.ValueString).HasMaxLength(255);
19+
20+
builder.HasIndex(a => a.FullPath);
21+
builder.HasIndex(a => a.ValueString);
1822
}
1923
}
2024
}

src/Scim/SimpleIdServer.Scim.Persistence.EF/SCIMDbContext.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ public class SCIMDbContext : DbContext
1111
{
1212
private readonly SCIMEFOptions _options;
1313

14-
public SCIMDbContext(DbContextOptions<SCIMDbContext> dbContextOptions, IOptions<SCIMEFOptions> options) : base(dbContextOptions)
14+
public SCIMDbContext(DbContextOptions<SCIMDbContext> dbContextOptions, IOptions<SCIMEFOptions> options): this((DbContextOptions)dbContextOptions, options)
15+
{
16+
17+
}
18+
19+
// protected constructor with generic options simplifies inheritance of the DbContext
20+
protected SCIMDbContext(DbContextOptions dbContextOptions, IOptions<SCIMEFOptions> options): base(dbContextOptions)
1521
{
1622
_options = options.Value;
1723
}

0 commit comments

Comments
 (0)