From b1dfbe75198f62092546066a351182b599559da7 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Mon, 9 Jan 2023 11:53:47 +0100 Subject: [PATCH] [SM-412] Remove postgres timezone legacy behavior (#2547) --- .config/dotnet-tools.json | 4 ++-- .../Repositories/DatabaseContext.cs | 18 ++++-------------- util/PostgresMigrations/Factories.cs | 3 --- 3 files changed, 6 insertions(+), 19 deletions(-) diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 469c0f953..1bc6d9a94 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -21,10 +21,10 @@ ] }, "dotnet-ef": { - "version": "6.0.11", + "version": "6.0.12", "commands": [ "dotnet-ef" ] } } -} +} \ No newline at end of file diff --git a/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs b/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs index 5068c29d9..e6cb64ec9 100644 --- a/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs +++ b/src/Infrastructure.EntityFramework/Repositories/DatabaseContext.cs @@ -157,20 +157,10 @@ public class DatabaseContext : DbContext { if (property.ClrType == typeof(DateTime) || property.ClrType == typeof(DateTime?)) { - if (Database.IsNpgsql()) - { - property.SetValueConverter( - new ValueConverter( - v => v, - v => v.ToUniversalTime())); - } - else - { - property.SetValueConverter( - new ValueConverter( - v => v, - v => new DateTime(v.Ticks, DateTimeKind.Utc))); - } + property.SetValueConverter( + new ValueConverter( + v => v, + v => new DateTime(v.Ticks, DateTimeKind.Utc))); } } } diff --git a/util/PostgresMigrations/Factories.cs b/util/PostgresMigrations/Factories.cs index 8d17045a2..b357597e9 100644 --- a/util/PostgresMigrations/Factories.cs +++ b/util/PostgresMigrations/Factories.cs @@ -25,9 +25,6 @@ public class DatabaseContextFactory : IDesignTimeDbContextFactory(); var connectionString = globalSettings.PostgreSql?.ConnectionString; - // NpgSql 6.0 changed how timezones works. We have not yet updated our projects to support this new behavior and need to fallback to the previous behavior. - // Check https://www.npgsql.org/doc/release-notes/6.0.html#timestamp-rationalization-and-improvements for more details. - AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); if (string.IsNullOrWhiteSpace(connectionString)) { throw new Exception("No Postgres connection string found.");