File tree Expand file tree Collapse file tree
Resgrid.Providers.MigrationsPg/Migrations
Resgrid.Providers.Migrations/Migrations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using FluentMigrator ;
2+ using FluentMigrator . SqlServer ;
23
34namespace Resgrid . Providers . Migrations . Migrations
45{
@@ -41,9 +42,14 @@ public override void Up()
4142 . OnColumn ( "LoggedOn" ) . Ascending ( ) ;
4243
4344 if ( ! Schema . Table ( "Calls" ) . Index ( "IX_Calls_DepartmentId_Type" ) . Exists ( ) )
45+ // Calls.Type is nvarchar(max), which SQL Server cannot use as an index key column
46+ // (error 1919), and existing data reaches ~1189 chars so it cannot be narrowed to a
47+ // keyable width without truncation. Key on DepartmentId and carry Type as an INCLUDE
48+ // (non-key) column -- LOB columns are allowed there -- which still covers the
49+ // dashboard's per-department GROUP BY Type aggregation.
4450 Create . Index ( "IX_Calls_DepartmentId_Type" ) . OnTable ( "Calls" )
4551 . OnColumn ( "DepartmentId" ) . Ascending ( )
46- . OnColumn ( "Type" ) . Ascending ( ) ;
52+ . Include ( "Type" ) ;
4753
4854 if ( ! Schema . Table ( "Calls" ) . Index ( "IX_Calls_DepartmentId_Priority" ) . Exists ( ) )
4955 Create . Index ( "IX_Calls_DepartmentId_Priority" ) . OnTable ( "Calls" )
Original file line number Diff line number Diff line change 11using FluentMigrator ;
2+ using FluentMigrator . Postgres ;
23
34namespace Resgrid . Providers . MigrationsPg . Migrations
45{
@@ -40,9 +41,13 @@ public override void Up()
4041 . OnColumn ( "LoggedOn" . ToLower ( ) ) . Ascending ( ) ;
4142
4243 if ( ! Schema . Table ( "Calls" . ToLower ( ) ) . Index ( "IX_Calls_DepartmentId_Type" . ToLower ( ) ) . Exists ( ) )
44+ // Mirrors the SQL Server variant: carry Type as an INCLUDE (non-key) column instead
45+ // of an index key, keeping the index shape symmetric across dialects and avoiding a
46+ // key on a free-form text column whose values reach ~1189 chars. Still covers the
47+ // dashboard's per-department GROUP BY Type aggregation.
4348 Create . Index ( "IX_Calls_DepartmentId_Type" . ToLower ( ) ) . OnTable ( "Calls" . ToLower ( ) )
4449 . OnColumn ( "DepartmentId" . ToLower ( ) ) . Ascending ( )
45- . OnColumn ( "Type" . ToLower ( ) ) . Ascending ( ) ;
50+ . Include ( "Type" . ToLower ( ) ) ;
4651
4752 if ( ! Schema . Table ( "Calls" . ToLower ( ) ) . Index ( "IX_Calls_DepartmentId_Priority" . ToLower ( ) ) . Exists ( ) )
4853 Create . Index ( "IX_Calls_DepartmentId_Priority" . ToLower ( ) ) . OnTable ( "Calls" . ToLower ( ) )
You can’t perform that action at this time.
0 commit comments