From 5b5025c7ad41e05dfe5f28d02fa86b586e8dd25c Mon Sep 17 00:00:00 2001 From: Ben Sampica Date: Wed, 6 Jul 2022 23:04:15 -0500 Subject: [PATCH] update migrations --- ...20220703013416_AddPlayerStateOfferMatchingToUnsigned.cs | 2 +- .../20220703022908_AddPlayerStateUnsignedToRostered.cs | 4 +++- .../20220703025848_AddPlayerStateRosteredToFreeAgent.cs | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Server/Infrastructure/Migrations/20220703013416_AddPlayerStateOfferMatchingToUnsigned.cs b/src/Server/Infrastructure/Migrations/20220703013416_AddPlayerStateOfferMatchingToUnsigned.cs index c245123..0eee385 100644 --- a/src/Server/Infrastructure/Migrations/20220703013416_AddPlayerStateOfferMatchingToUnsigned.cs +++ b/src/Server/Infrastructure/Migrations/20220703013416_AddPlayerStateOfferMatchingToUnsigned.cs @@ -12,7 +12,7 @@ protected override void Up(MigrationBuilder migrationBuilder) // Convert Offer Matches to use state. var sql = $@"UPDATE Players SET State = 1 - WHERE DATEADD(day, 3, {nameof(Player.EndOfFreeAgency)}) <= getdate()"; + WHERE DATEADD(day, 3, {nameof(Player.EndOfFreeAgency)}) >= getdate()"; migrationBuilder.Sql(sql); } diff --git a/src/Server/Infrastructure/Migrations/20220703022908_AddPlayerStateUnsignedToRostered.cs b/src/Server/Infrastructure/Migrations/20220703022908_AddPlayerStateUnsignedToRostered.cs index bfa1e5d..20878cc 100644 --- a/src/Server/Infrastructure/Migrations/20220703022908_AddPlayerStateUnsignedToRostered.cs +++ b/src/Server/Infrastructure/Migrations/20220703022908_AddPlayerStateUnsignedToRostered.cs @@ -12,7 +12,9 @@ protected override void Up(MigrationBuilder migrationBuilder) // Convert Unsigned to use state. var sql = $@"UPDATE Players SET State = 2 - WHERE DATEADD(day, 3, {nameof(Player.EndOfFreeAgency)}) >= getdate()"; + WHERE {nameof(Player.EndOfFreeAgency)} IS NULL + AND {nameof(Player.YearContractExpires)} IS NULL + AND {nameof(Player.YearAcquired)} = 2022"; migrationBuilder.Sql(sql); } diff --git a/src/Server/Infrastructure/Migrations/20220703025848_AddPlayerStateRosteredToFreeAgent.cs b/src/Server/Infrastructure/Migrations/20220703025848_AddPlayerStateRosteredToFreeAgent.cs index d06fa26..53bed72 100644 --- a/src/Server/Infrastructure/Migrations/20220703025848_AddPlayerStateRosteredToFreeAgent.cs +++ b/src/Server/Infrastructure/Migrations/20220703025848_AddPlayerStateRosteredToFreeAgent.cs @@ -8,6 +8,13 @@ public partial class AddPlayerStateRosteredToFreeAgent : Migration { protected override void Up(MigrationBuilder migrationBuilder) { + // Data cleansing - this shouldn't be happening. + var sql2 = $@"UPDATE Players + SET Rostered = 0 + WHERE EndOfFreeAgency IS NOT NULL"; + + migrationBuilder.Sql(sql2); + // Convert Signed to use state. var sql = $@"UPDATE Players SET State = 3