Fix admin log indices. (#7920)

This commit is contained in:
Pieter-Jan Briers 2022-05-04 16:18:55 +02:00 committed by GitHub
parent faec39da2b
commit fc119befca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 2521 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,45 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Content.Server.Database.Migrations.Postgres
{
public partial class FixIndices : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_admin_log_message",
table: "admin_log");
migrationBuilder.CreateIndex(
name: "IX_admin_log_date",
table: "admin_log",
column: "date");
migrationBuilder.CreateIndex(
name: "IX_admin_log_message",
table: "admin_log",
column: "message")
.Annotation("Npgsql:IndexMethod", "GIN")
.Annotation("Npgsql:TsVectorConfig", "english");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_admin_log_date",
table: "admin_log");
migrationBuilder.DropIndex(
name: "IX_admin_log_message",
table: "admin_log");
migrationBuilder.CreateIndex(
name: "IX_admin_log_message",
table: "admin_log",
column: "message")
.Annotation("Npgsql:TsVectorConfig", "english");
}
}
}

View File

@ -120,9 +120,13 @@ namespace Content.Server.Database.Migrations.Postgres
b.HasKey("Id", "RoundId")
.HasName("PK_admin_log");
b.HasIndex("Date");
b.HasIndex("Message")
.HasAnnotation("Npgsql:TsVectorConfig", "english");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Message"), "GIN");
b.HasIndex("RoundId")
.HasDatabaseName("IX_admin_log_round_id");

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,24 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Content.Server.Database.Migrations.Sqlite
{
public partial class FixIndices : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_admin_log_date",
table: "admin_log",
column: "date");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_admin_log_date",
table: "admin_log");
}
}
}

View File

@ -109,6 +109,8 @@ namespace Content.Server.Database.Migrations.Sqlite
b.HasKey("Id", "RoundId")
.HasName("PK_admin_log");
b.HasIndex("Date");
b.HasIndex("RoundId")
.HasDatabaseName("IX_admin_log_round_id");

View File

@ -91,6 +91,9 @@ namespace Content.Server.Database
.Property(log => log.Id)
.ValueGeneratedOnAdd();
modelBuilder.Entity<AdminLog>()
.HasIndex(log => log.Date);
modelBuilder.Entity<AdminLogPlayer>()
.HasOne(player => player.Player)
.WithMany(player => player.AdminLogs)

View File

@ -63,6 +63,7 @@ namespace Content.Server.Database
modelBuilder.Entity<AdminLog>()
.HasIndex(l => l.Message)
.HasMethod("GIN")
.IsTsVectorExpressionIndex("english");
foreach(var entity in modelBuilder.Model.GetEntityTypes())