mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 07:36:14 -05:00
[BEEEP] [SM-1059] Add missing auth table indexes to EF config (#3625)
* Add missing indexes to EF auth tables * Add EF migrations
This commit is contained in:
@ -21,6 +21,10 @@ public class GrantEntityTypeConfiguration : IEntityTypeConfiguration<Grant>
|
||||
.HasIndex(s => s.Key)
|
||||
.IsUnique(true);
|
||||
|
||||
builder
|
||||
.HasIndex(s => s.ExpirationDate)
|
||||
.IsClustered(false);
|
||||
|
||||
builder.ToTable(nameof(Grant));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,28 @@
|
||||
using Bit.Infrastructure.EntityFramework.Auth.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.Auth.Configurations;
|
||||
|
||||
public class SsoUserEntityTypeConfiguration : IEntityTypeConfiguration<SsoUser>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<SsoUser> builder)
|
||||
{
|
||||
builder
|
||||
.HasIndex(su => su.OrganizationId)
|
||||
.IsClustered(false);
|
||||
|
||||
NpgsqlIndexBuilderExtensions.IncludeProperties(
|
||||
builder.HasIndex(su => new { su.OrganizationId, su.ExternalId })
|
||||
.IsUnique()
|
||||
.IsClustered(false),
|
||||
su => su.UserId);
|
||||
|
||||
builder
|
||||
.HasIndex(su => new { su.OrganizationId, su.UserId })
|
||||
.IsUnique()
|
||||
.IsClustered(false);
|
||||
|
||||
builder.ToTable(nameof(SsoUser));
|
||||
}
|
||||
}
|
@ -86,7 +86,6 @@ public class DatabaseContext : DbContext
|
||||
var eProviderUser = builder.Entity<ProviderUser>();
|
||||
var eProviderOrganization = builder.Entity<ProviderOrganization>();
|
||||
var eSsoConfig = builder.Entity<SsoConfig>();
|
||||
var eSsoUser = builder.Entity<SsoUser>();
|
||||
var eTaxRate = builder.Entity<TaxRate>();
|
||||
var eUser = builder.Entity<User>();
|
||||
var eOrganizationApiKey = builder.Entity<OrganizationApiKey>();
|
||||
@ -125,8 +124,8 @@ public class DatabaseContext : DbContext
|
||||
// see https://www.npgsql.org/efcore/misc/collations-and-case-sensitivity.html#database-collation
|
||||
builder.HasCollation(postgresIndetermanisticCollation, locale: "en-u-ks-primary", provider: "icu", deterministic: false);
|
||||
eUser.Property(e => e.Email).UseCollation(postgresIndetermanisticCollation);
|
||||
eSsoUser.Property(e => e.ExternalId).UseCollation(postgresIndetermanisticCollation);
|
||||
builder.Entity<Organization>().Property(e => e.Identifier).UseCollation(postgresIndetermanisticCollation);
|
||||
builder.Entity<SsoUser>().Property(e => e.ExternalId).UseCollation(postgresIndetermanisticCollation);
|
||||
//
|
||||
}
|
||||
|
||||
@ -142,7 +141,6 @@ public class DatabaseContext : DbContext
|
||||
eProviderUser.ToTable(nameof(ProviderUser));
|
||||
eProviderOrganization.ToTable(nameof(ProviderOrganization));
|
||||
eSsoConfig.ToTable(nameof(SsoConfig));
|
||||
eSsoUser.ToTable(nameof(SsoUser));
|
||||
eTaxRate.ToTable(nameof(TaxRate));
|
||||
eOrganizationApiKey.ToTable(nameof(OrganizationApiKey));
|
||||
eOrganizationConnection.ToTable(nameof(OrganizationConnection));
|
||||
|
Reference in New Issue
Block a user