fix(migrations): shrink SiteCode and InternalWONumber before Phase4 search indexes

SQL Server cannot index nvarchar(max). Alter columns to nvarchar(450)
before creating Phase 4 search indexes.
This commit is contained in:
Arthur Bassi 2026-07-17 10:36:31 -03:00
parent 11fed06f03
commit 54cd24acf4

View file

@ -10,6 +10,27 @@ namespace Data.SeaHavenIndustries.Migrations
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
// nvarchar(max) cannot be an index key; shrink before indexing.
migrationBuilder.AlterColumn<string>(
name: "SiteCode",
table: "workOrders",
type: "nvarchar(450)",
maxLength: 450,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "InternalWONumber",
table: "workOrders",
type: "nvarchar(450)",
maxLength: 450,
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_workOrders_SiteCode", name: "IX_workOrders_SiteCode",
table: "workOrders", table: "workOrders",
@ -43,6 +64,26 @@ namespace Data.SeaHavenIndustries.Migrations
migrationBuilder.DropIndex( migrationBuilder.DropIndex(
name: "IX_workOrders_LifecycleStatus_ScheduledDate", name: "IX_workOrders_LifecycleStatus_ScheduledDate",
table: "workOrders"); table: "workOrders");
migrationBuilder.AlterColumn<string>(
name: "SiteCode",
table: "workOrders",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldMaxLength: 450,
oldNullable: true);
migrationBuilder.AlterColumn<string>(
name: "InternalWONumber",
table: "workOrders",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(450)",
oldMaxLength: 450,
oldNullable: true);
} }
} }
} }