48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
using CvMatcher.Data;
|
|
|
|
#nullable disable
|
|
|
|
namespace CvMatcher.Data.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class UpdateResultsUniqueConstraintToIncludeLanguage : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
// The Language column was added in migration 20260524140335, but the unique constraint
|
|
// was never updated from (CvDocumentId, JobDocumentId) to include Language.
|
|
// This caused duplicate key violations when matching the same CV+Job in different languages.
|
|
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Results_CvDocumentId_JobDocumentId",
|
|
schema: MigrationConstants.SchemaName,
|
|
table: "Results");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Results_CvDocumentId_JobDocumentId_Language",
|
|
schema: MigrationConstants.SchemaName,
|
|
table: "Results",
|
|
columns: new[] { "CvDocumentId", "JobDocumentId", "Language" },
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropIndex(
|
|
name: "IX_Results_CvDocumentId_JobDocumentId_Language",
|
|
schema: MigrationConstants.SchemaName,
|
|
table: "Results");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_Results_CvDocumentId_JobDocumentId",
|
|
schema: MigrationConstants.SchemaName,
|
|
table: "Results",
|
|
columns: new[] { "CvDocumentId", "JobDocumentId" },
|
|
unique: true);
|
|
}
|
|
}
|
|
}
|