Partial index (filter: "Status" = 0) replaces the unconditional unique index on (GuildId, InviteeViewerId). Old Rejected/Canceled rows no longer conflict when a new Pending invite is inserted for the same pair. Adds regression tests: Reinvite_after_reject_succeeds and Reinvite_after_cancel_succeeds. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace SVSim.Database.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class MakeGuildInviteUniqueIndexPartial : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_GuildInvites_GuildId_InviteeViewerId",
|
|
table: "GuildInvites");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GuildInvites_GuildId_InviteeViewerId",
|
|
table: "GuildInvites",
|
|
columns: new[] { "GuildId", "InviteeViewerId" },
|
|
unique: true,
|
|
filter: "\"Status\" = 0");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_GuildInvites_GuildId_InviteeViewerId",
|
|
table: "GuildInvites");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_GuildInvites_GuildId_InviteeViewerId",
|
|
table: "GuildInvites",
|
|
columns: new[] { "GuildId", "InviteeViewerId" },
|
|
unique: true);
|
|
}
|
|
}
|
|
}
|