From 9f7424ba58be9bb8bdd3e7931eeb206a061e198d Mon Sep 17 00:00:00 2001 From: Shawn Jackson Date: Mon, 8 Jun 2026 14:52:23 -0500 Subject: [PATCH] RE1-T117 Fixing migration issue --- .../Migrations/M0073_AddingReportingIndexes.cs | 8 +++++++- .../Migrations/M0073_AddingReportingIndexesPg.cs | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Providers/Resgrid.Providers.Migrations/Migrations/M0073_AddingReportingIndexes.cs b/Providers/Resgrid.Providers.Migrations/Migrations/M0073_AddingReportingIndexes.cs index d36b00f82..3799b2ada 100644 --- a/Providers/Resgrid.Providers.Migrations/Migrations/M0073_AddingReportingIndexes.cs +++ b/Providers/Resgrid.Providers.Migrations/Migrations/M0073_AddingReportingIndexes.cs @@ -1,4 +1,5 @@ using FluentMigrator; +using FluentMigrator.SqlServer; namespace Resgrid.Providers.Migrations.Migrations { @@ -41,9 +42,14 @@ public override void Up() .OnColumn("LoggedOn").Ascending(); if (!Schema.Table("Calls").Index("IX_Calls_DepartmentId_Type").Exists()) + // Calls.Type is nvarchar(max), which SQL Server cannot use as an index key column + // (error 1919), and existing data reaches ~1189 chars so it cannot be narrowed to a + // keyable width without truncation. Key on DepartmentId and carry Type as an INCLUDE + // (non-key) column -- LOB columns are allowed there -- which still covers the + // dashboard's per-department GROUP BY Type aggregation. Create.Index("IX_Calls_DepartmentId_Type").OnTable("Calls") .OnColumn("DepartmentId").Ascending() - .OnColumn("Type").Ascending(); + .Include("Type"); if (!Schema.Table("Calls").Index("IX_Calls_DepartmentId_Priority").Exists()) Create.Index("IX_Calls_DepartmentId_Priority").OnTable("Calls") diff --git a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0073_AddingReportingIndexesPg.cs b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0073_AddingReportingIndexesPg.cs index efbc9d9dd..14d1323c8 100644 --- a/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0073_AddingReportingIndexesPg.cs +++ b/Providers/Resgrid.Providers.MigrationsPg/Migrations/M0073_AddingReportingIndexesPg.cs @@ -1,4 +1,5 @@ using FluentMigrator; +using FluentMigrator.Postgres; namespace Resgrid.Providers.MigrationsPg.Migrations { @@ -40,9 +41,13 @@ public override void Up() .OnColumn("LoggedOn".ToLower()).Ascending(); if (!Schema.Table("Calls".ToLower()).Index("IX_Calls_DepartmentId_Type".ToLower()).Exists()) + // Mirrors the SQL Server variant: carry Type as an INCLUDE (non-key) column instead + // of an index key, keeping the index shape symmetric across dialects and avoiding a + // key on a free-form text column whose values reach ~1189 chars. Still covers the + // dashboard's per-department GROUP BY Type aggregation. Create.Index("IX_Calls_DepartmentId_Type".ToLower()).OnTable("Calls".ToLower()) .OnColumn("DepartmentId".ToLower()).Ascending() - .OnColumn("Type".ToLower()).Ascending(); + .Include("Type".ToLower()); if (!Schema.Table("Calls".ToLower()).Index("IX_Calls_DepartmentId_Priority".ToLower()).Exists()) Create.Index("IX_Calls_DepartmentId_Priority".ToLower()).OnTable("Calls".ToLower())