[backend/database] Remove redundant index on the marker table

This index is identical to the composite primary key, and therefore redundant.
This commit is contained in:
Laura Hausmann 2024-04-19 20:19:25 +02:00
parent 79c3a9c891
commit e04665f9d7
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 31 additions and 4 deletions

View file

@ -1638,9 +1638,6 @@ namespace Iceshrimp.Backend.Core.Database.Migrations
b.HasIndex("UserId");
b.HasIndex("UserId", "Type")
.IsUnique();
b.ToTable("marker");
});

View file

@ -0,0 +1,31 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Infrastructure;
#nullable disable
namespace Iceshrimp.Backend.Core.Database.Migrations
{
/// <inheritdoc />
[DbContext(typeof(DatabaseContext))]
[Migration("20240419181840_RemoveRedundantMarkerIndex")]
public partial class RemoveRedundantMarkerIndex : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_marker_userId_type",
table: "marker");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateIndex(
name: "IX_marker_userId_type",
table: "marker",
columns: new[] { "userId", "type" },
unique: true);
}
}
}

View file

@ -7,7 +7,6 @@ namespace Iceshrimp.Backend.Core.Database.Tables;
[Table("marker")]
[Index(nameof(UserId))]
[Index(nameof(UserId), nameof(Type), IsUnique = true)]
[PrimaryKey(nameof(UserId), nameof(Type))]
public class Marker
{