From 7dd5c8a27ec5ae5efbfc1d32979fb64881c5729d Mon Sep 17 00:00:00 2001 From: Simon <63975668+Simyon264@users.noreply.github.com> Date: Wed, 3 Apr 2024 00:36:17 +0200 Subject: [PATCH] Remove RoundEndText indexing Caused indexing issues when the text was too long lmao, this made the server try to redownload the errored file. This caused me to use 2TB of download in 1.5 days. Yipee! --- Server/Api/ReplayDbContext.cs | 3 +- ...222948_RemoveRoundEndTextIndex.Designer.cs | 169 ++++++++++++++++++ .../20240402222948_RemoveRoundEndTextIndex.cs | 27 +++ .../ReplayDbContextModelSnapshot.cs | 2 - 4 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 Server/Migrations/20240402222948_RemoveRoundEndTextIndex.Designer.cs create mode 100644 Server/Migrations/20240402222948_RemoveRoundEndTextIndex.cs diff --git a/Server/Api/ReplayDbContext.cs b/Server/Api/ReplayDbContext.cs index 9f158d3..5b44183 100644 --- a/Server/Api/ReplayDbContext.cs +++ b/Server/Api/ReplayDbContext.cs @@ -22,8 +22,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .HasIndex(r => r.Gamemode); modelBuilder.Entity() .HasIndex(r => r.ServerId); - modelBuilder.Entity() - .HasIndex(r => r.RoundEndText); + modelBuilder.Entity(); modelBuilder.Entity() .HasIndex(r => r.ServerName); modelBuilder.Entity() diff --git a/Server/Migrations/20240402222948_RemoveRoundEndTextIndex.Designer.cs b/Server/Migrations/20240402222948_RemoveRoundEndTextIndex.Designer.cs new file mode 100644 index 0000000..d2637b9 --- /dev/null +++ b/Server/Migrations/20240402222948_RemoveRoundEndTextIndex.Designer.cs @@ -0,0 +1,169 @@ +// +using System; +using System.Collections.Generic; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; +using Server.Api; + +#nullable disable + +namespace Server.Migrations +{ + [DbContext(typeof(ReplayDbContext))] + [Migration("20240402222948_RemoveRoundEndTextIndex")] + partial class RemoveRoundEndTextIndex + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Shared.Models.ParsedReplay", b => + { + b.Property("Name") + .HasColumnType("text"); + + b.HasKey("Name"); + + b.ToTable("ParsedReplays", (string)null); + }); + + modelBuilder.Entity("Shared.Models.Player", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Antag") + .HasColumnType("boolean"); + + b.Property>("AntagPrototypes") + .IsRequired() + .HasColumnType("text[]"); + + b.Property>("JobPrototypes") + .IsRequired() + .HasColumnType("text[]"); + + b.Property("PlayerGuid") + .HasColumnType("uuid"); + + b.Property("PlayerIcName") + .IsRequired() + .HasColumnType("text"); + + b.Property("PlayerOocName") + .IsRequired() + .HasColumnType("text"); + + b.Property("ReplayId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("PlayerGuid"); + + b.HasIndex("PlayerIcName"); + + b.HasIndex("PlayerOocName"); + + b.HasIndex("ReplayId"); + + b.ToTable("Players", (string)null); + }); + + modelBuilder.Entity("Shared.Models.Replay", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Date") + .HasColumnType("timestamp with time zone"); + + b.Property("Duration") + .IsRequired() + .HasColumnType("text"); + + b.Property("EndTick") + .HasColumnType("integer"); + + b.Property("EndTime") + .IsRequired() + .HasColumnType("text"); + + b.Property("FileCount") + .HasColumnType("integer"); + + b.Property("Gamemode") + .IsRequired() + .HasColumnType("text"); + + b.Property("Link") + .HasColumnType("text"); + + b.Property("Map") + .IsRequired() + .HasColumnType("text"); + + b.Property("RoundEndText") + .HasColumnType("text"); + + b.Property("RoundId") + .HasColumnType("integer"); + + b.Property("ServerId") + .IsRequired() + .HasColumnType("text"); + + b.Property("ServerName") + .HasColumnType("text"); + + b.Property("Size") + .HasColumnType("integer"); + + b.Property("UncompressedSize") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("Gamemode"); + + b.HasIndex("Map"); + + b.HasIndex("ServerId"); + + b.HasIndex("ServerName"); + + b.ToTable("Replays", (string)null); + }); + + modelBuilder.Entity("Shared.Models.Player", b => + { + b.HasOne("Shared.Models.Replay", "Replay") + .WithMany("RoundEndPlayers") + .HasForeignKey("ReplayId"); + + b.Navigation("Replay"); + }); + + modelBuilder.Entity("Shared.Models.Replay", b => + { + b.Navigation("RoundEndPlayers"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Server/Migrations/20240402222948_RemoveRoundEndTextIndex.cs b/Server/Migrations/20240402222948_RemoveRoundEndTextIndex.cs new file mode 100644 index 0000000..c8b05ba --- /dev/null +++ b/Server/Migrations/20240402222948_RemoveRoundEndTextIndex.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Server.Migrations +{ + /// + public partial class RemoveRoundEndTextIndex : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Replays_RoundEndText", + table: "Replays"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_Replays_RoundEndText", + table: "Replays", + column: "RoundEndText"); + } + } +} diff --git a/Server/Migrations/ReplayDbContextModelSnapshot.cs b/Server/Migrations/ReplayDbContextModelSnapshot.cs index 706e076..89a513c 100644 --- a/Server/Migrations/ReplayDbContextModelSnapshot.cs +++ b/Server/Migrations/ReplayDbContextModelSnapshot.cs @@ -140,8 +140,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("Map"); - b.HasIndex("RoundEndText"); - b.HasIndex("ServerId"); b.HasIndex("ServerName");