Fixing a timezone issue

This commit is contained in:
David Benson 2023-12-12 12:43:50 -05:00
commit 49102ba61c
No known key found for this signature in database
GPG key ID: AEB25FAA80437D26
2 changed files with 18 additions and 1 deletions

View file

@ -0,0 +1,17 @@
using System;
using System.Runtime.CompilerServices;
namespace Ombi.Store.Context.Postgres;
public static class PostgresModuleInitializer
{
#pragma warning disable CA2255
// This is required to ensure that Npgsql uses a timestamp behavior that does not require a timezone
// Reference: https://stackoverflow.com/a/73586129
[ModuleInitializer]
#pragma warning restore CA2255
public static void Initialize()
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
}
}

View file

@ -120,6 +120,7 @@ namespace Ombi
serviceProvider.UseQuartz().GetAwaiter().GetResult(); serviceProvider.UseQuartz().GetAwaiter().GetResult();
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
var ctx = serviceProvider.GetService<OmbiContext>(); var ctx = serviceProvider.GetService<OmbiContext>();
loggerFactory.AddSerilog(); loggerFactory.AddSerilog();
var ombiService = var ombiService =
@ -151,7 +152,6 @@ namespace Ombi
{ {
app.UsePathBase(settings.BaseUrl); app.UsePathBase(settings.BaseUrl);
} }
ctx.Seed(); ctx.Seed();
var settingsctx = serviceProvider.GetService<SettingsContext>(); var settingsctx = serviceProvider.GetService<SettingsContext>();
settingsctx.Seed(); settingsctx.Seed();