1
0
mirror of https://github.com/bitwarden/server.git synced 2025-06-30 07:36:14 -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:
Thomas Avery
2024-01-10 12:03:16 -06:00
committed by GitHub
parent 956efbdb39
commit 3392ede534
18 changed files with 7823 additions and 44 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,112 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Bit.PostgresMigrations.Migrations;
/// <inheritdoc />
public partial class AddTableIndexes : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_User_Email",
table: "User",
column: "Email",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_User_Premium_PremiumExpirationDate_RenewalReminderDate",
table: "User",
columns: new[] { "Premium", "PremiumExpirationDate", "RenewalReminderDate" });
migrationBuilder.CreateIndex(
name: "IX_Transaction_UserId_OrganizationId_CreationDate",
table: "Transaction",
columns: new[] { "UserId", "OrganizationId", "CreationDate" });
migrationBuilder.CreateIndex(
name: "IX_Policy_OrganizationId_Type",
table: "Policy",
columns: new[] { "OrganizationId", "Type" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_OrganizationUser_UserId_OrganizationId_Status",
table: "OrganizationUser",
columns: new[] { "UserId", "OrganizationId", "Status" })
.Annotation("Npgsql:IndexInclude", new[] { "AccessAll" });
migrationBuilder.CreateIndex(
name: "IX_OrganizationSponsorship_SponsoringOrganizationUserId",
table: "OrganizationSponsorship",
column: "SponsoringOrganizationUserId");
migrationBuilder.CreateIndex(
name: "IX_Organization_Id_Enabled",
table: "Organization",
columns: new[] { "Id", "Enabled" })
.Annotation("Npgsql:IndexInclude", new[] { "UseTotp" });
migrationBuilder.CreateIndex(
name: "IX_Event_Date_OrganizationId_ActingUserId_CipherId",
table: "Event",
columns: new[] { "Date", "OrganizationId", "ActingUserId", "CipherId" });
migrationBuilder.CreateIndex(
name: "IX_Device_Identifier",
table: "Device",
column: "Identifier");
migrationBuilder.CreateIndex(
name: "IX_Device_UserId_Identifier",
table: "Device",
columns: new[] { "UserId", "Identifier" },
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_User_Email",
table: "User");
migrationBuilder.DropIndex(
name: "IX_User_Premium_PremiumExpirationDate_RenewalReminderDate",
table: "User");
migrationBuilder.DropIndex(
name: "IX_Transaction_UserId_OrganizationId_CreationDate",
table: "Transaction");
migrationBuilder.DropIndex(
name: "IX_Policy_OrganizationId_Type",
table: "Policy");
migrationBuilder.DropIndex(
name: "IX_OrganizationUser_UserId_OrganizationId_Status",
table: "OrganizationUser");
migrationBuilder.DropIndex(
name: "IX_OrganizationSponsorship_SponsoringOrganizationUserId",
table: "OrganizationSponsorship");
migrationBuilder.DropIndex(
name: "IX_Organization_Id_Enabled",
table: "Organization");
migrationBuilder.DropIndex(
name: "IX_Event_Date_OrganizationId_ActingUserId_CipherId",
table: "Event");
migrationBuilder.DropIndex(
name: "IX_Device_Identifier",
table: "Device");
migrationBuilder.DropIndex(
name: "IX_Device_UserId_Identifier",
table: "Device");
}
}

View File

@ -205,6 +205,10 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Id", "Enabled");
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("Id", "Enabled"), new[] { "UseTotp" });
b.ToTable("Organization", (string)null);
});
@ -233,7 +237,12 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("OrganizationId");
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("OrganizationId", "Type")
.IsUnique()
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Policy", (string)null);
});
@ -786,7 +795,15 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("Identifier")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "Identifier")
.IsUnique()
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Device", (string)null);
});
@ -859,6 +876,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Date", "OrganizationId", "ActingUserId", "CipherId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Event", (string)null);
});
@ -1059,6 +1079,9 @@ namespace Bit.PostgresMigrations.Migrations
b.HasIndex("SponsoringOrganizationId");
b.HasIndex("SponsoringOrganizationUserId")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("OrganizationSponsorship", (string)null);
});
@ -1110,9 +1133,16 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("OrganizationId");
b.HasIndex("OrganizationId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId", "Status")
.HasAnnotation("SqlServer:Clustered", false);
NpgsqlIndexBuilderExtensions.IncludeProperties(b.HasIndex("UserId", "OrganizationId", "Status"), new[] { "AccessAll" });
b.ToTable("OrganizationUser", (string)null);
});
@ -1254,7 +1284,11 @@ namespace Bit.PostgresMigrations.Migrations
b.HasIndex("OrganizationId");
b.HasIndex("UserId");
b.HasIndex("UserId")
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("UserId", "OrganizationId", "CreationDate")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("Transaction", (string)null);
});
@ -1405,6 +1439,13 @@ namespace Bit.PostgresMigrations.Migrations
b.HasKey("Id");
b.HasIndex("Email")
.IsUnique()
.HasAnnotation("SqlServer:Clustered", false);
b.HasIndex("Premium", "PremiumExpirationDate", "RenewalReminderDate")
.HasAnnotation("SqlServer:Clustered", false);
b.ToTable("User", (string)null);
});