mirror of
https://github.com/bitwarden/server.git
synced 2025-07-02 00:22:50 -05:00
[BEEEP][SM-1062] Add missing table indexes to EF config (#3628)
* Add missing EF indexes * Add EF migrations * move configs * regenerate migrations
This commit is contained in:
@ -0,0 +1,29 @@
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Configurations;
|
||||
|
||||
public class OrganizationEntityTypeConfiguration : IEntityTypeConfiguration<Organization>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Organization> builder)
|
||||
{
|
||||
builder
|
||||
.Property(o => o.Id)
|
||||
.ValueGeneratedNever();
|
||||
|
||||
builder.Property(c => c.LimitCollectionCreationDeletion)
|
||||
.ValueGeneratedNever()
|
||||
.HasDefaultValue(true);
|
||||
|
||||
builder.Property(c => c.AllowAdminAccessToAllCollectionItems)
|
||||
.ValueGeneratedNever()
|
||||
.HasDefaultValue(true);
|
||||
|
||||
NpgsqlIndexBuilderExtensions.IncludeProperties(
|
||||
builder.HasIndex(o => new { o.Id, o.Enabled }),
|
||||
o => o.UseTotp);
|
||||
|
||||
builder.ToTable(nameof(Organization));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
using Bit.Infrastructure.EntityFramework.AdminConsole.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace Bit.Infrastructure.EntityFramework.AdminConsole.Configurations;
|
||||
|
||||
public class PolicyEntityTypeConfiguration : IEntityTypeConfiguration<Policy>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<Policy> builder)
|
||||
{
|
||||
builder
|
||||
.Property(p => p.Id)
|
||||
.ValueGeneratedNever();
|
||||
|
||||
builder
|
||||
.HasIndex(p => p.OrganizationId)
|
||||
.IsClustered(false);
|
||||
|
||||
builder
|
||||
.HasIndex(p => new { p.OrganizationId, p.Type })
|
||||
.IsUnique()
|
||||
.IsClustered(false);
|
||||
|
||||
builder.ToTable(nameof(Policy));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user