1
0
mirror of https://github.com/bitwarden/server.git synced 2025-04-05 13:08:17 -05:00

[BEEEP] [SM-1060] Add missing tools table indexes to EF config (#3626)

* Add missing indexes

* Add EF migrations
This commit is contained in:
Thomas Avery 2024-01-09 09:46:45 -06:00 committed by GitHub
parent 8daa754ecb
commit a480bd16e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 7192 additions and 6 deletions

View File

@ -91,7 +91,6 @@ public class DatabaseContext : DbContext
var eProvider = builder.Entity<Provider>();
var eProviderUser = builder.Entity<ProviderUser>();
var eProviderOrganization = builder.Entity<ProviderOrganization>();
var eSend = builder.Entity<Send>();
var eSsoConfig = builder.Entity<SsoConfig>();
var eSsoUser = builder.Entity<SsoUser>();
var eTaxRate = builder.Entity<TaxRate>();
@ -122,7 +121,6 @@ public class DatabaseContext : DbContext
eProvider.Property(c => c.Id).ValueGeneratedNever();
eProviderUser.Property(c => c.Id).ValueGeneratedNever();
eProviderOrganization.Property(c => c.Id).ValueGeneratedNever();
eSend.Property(c => c.Id).ValueGeneratedNever();
eTransaction.Property(c => c.Id).ValueGeneratedNever();
eUser.Property(c => c.Id).ValueGeneratedNever();
eOrganizationApiKey.Property(c => c.Id).ValueGeneratedNever();
@ -169,7 +167,6 @@ public class DatabaseContext : DbContext
eProvider.ToTable(nameof(Provider));
eProviderUser.ToTable(nameof(ProviderUser));
eProviderOrganization.ToTable(nameof(ProviderOrganization));
eSend.ToTable(nameof(Send));
eSsoConfig.ToTable(nameof(SsoConfig));
eSsoUser.ToTable(nameof(SsoUser));
eTaxRate.ToTable(nameof(TaxRate));

View File

@ -0,0 +1,29 @@
using Bit.Infrastructure.EntityFramework.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Bit.Infrastructure.EntityFramework.Tools.Configurations;
public class SendEntityTypeConfiguration : IEntityTypeConfiguration<Send>
{
public void Configure(EntityTypeBuilder<Send> builder)
{
builder
.Property(s => s.Id)
.ValueGeneratedNever();
builder
.HasIndex(s => s.UserId)
.IsClustered(false);
builder
.HasIndex(s => new { s.UserId, s.OrganizationId })
.IsClustered(false);
builder
.HasIndex(s => s.DeletionDate)
.IsClustered(false);
builder.ToTable(nameof(Send));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.MySqlMigrations.Migrations;
/// <inheritdoc />
public partial class AddToolsTableIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Send_DeletionDate",
table: "Send",
column: "DeletionDate");
migrationBuilder.CreateIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send",
columns: new[] { "UserId", "OrganizationId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Send_DeletionDate",
table: "Send");
migrationBuilder.DropIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send");
}
}

View File

@ -1155,9 +1155,16 @@ namespace Bit.MySqlMigrations.Migrations
b.HasKey("Id");
b.HasIndex("DeletionDate")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId");
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Send", (string)null);
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class AddToolsTableIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Send_DeletionDate",
table: "Send",
column: "DeletionDate");
migrationBuilder.CreateIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send",
columns: new[] { "UserId", "OrganizationId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Send_DeletionDate",
table: "Send");
migrationBuilder.DropIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send");
}
}

View File

@ -1167,9 +1167,16 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("DeletionDate")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId");
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Send", (string)null);
});

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,35 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.SqliteMigrations.Migrations;
/// <inheritdoc />
public partial class AddToolsTableIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_Send_DeletionDate",
table: "Send",
column: "DeletionDate");
migrationBuilder.CreateIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send",
columns: new[] { "UserId", "OrganizationId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Send_DeletionDate",
table: "Send");
migrationBuilder.DropIndex(
name: "IX_Send_UserId_OrganizationId",
table: "Send");
}
}

View File

@ -1153,9 +1153,16 @@ namespace Bit.SqliteMigrations.Migrations
b.HasKey("Id");
b.HasIndex("DeletionDate")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId");
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Send", (string)null);
});