mirror of
https://github.com/bitwarden/server.git
synced 2024-11-22 12:15:36 +01:00
[SM-412] Remove postgres timezone legacy behavior (#2547)
This commit is contained in:
parent
452891b39e
commit
b1dfbe7519
@ -21,7 +21,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"dotnet-ef": {
|
"dotnet-ef": {
|
||||||
"version": "6.0.11",
|
"version": "6.0.12",
|
||||||
"commands": [
|
"commands": [
|
||||||
"dotnet-ef"
|
"dotnet-ef"
|
||||||
]
|
]
|
||||||
|
@ -156,15 +156,6 @@ public class DatabaseContext : DbContext
|
|||||||
foreach (var property in entityType.GetProperties())
|
foreach (var property in entityType.GetProperties())
|
||||||
{
|
{
|
||||||
if (property.ClrType == typeof(DateTime) || property.ClrType == typeof(DateTime?))
|
if (property.ClrType == typeof(DateTime) || property.ClrType == typeof(DateTime?))
|
||||||
{
|
|
||||||
if (Database.IsNpgsql())
|
|
||||||
{
|
|
||||||
property.SetValueConverter(
|
|
||||||
new ValueConverter<DateTime, DateTime>(
|
|
||||||
v => v,
|
|
||||||
v => v.ToUniversalTime()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
property.SetValueConverter(
|
property.SetValueConverter(
|
||||||
new ValueConverter<DateTime, DateTime>(
|
new ValueConverter<DateTime, DateTime>(
|
||||||
@ -175,4 +166,3 @@ public class DatabaseContext : DbContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -25,9 +25,6 @@ public class DatabaseContextFactory : IDesignTimeDbContextFactory<DatabaseContex
|
|||||||
var globalSettings = GlobalSettingsFactory.GlobalSettings;
|
var globalSettings = GlobalSettingsFactory.GlobalSettings;
|
||||||
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
|
var optionsBuilder = new DbContextOptionsBuilder<DatabaseContext>();
|
||||||
var connectionString = globalSettings.PostgreSql?.ConnectionString;
|
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))
|
if (string.IsNullOrWhiteSpace(connectionString))
|
||||||
{
|
{
|
||||||
throw new Exception("No Postgres connection string found.");
|
throw new Exception("No Postgres connection string found.");
|
||||||
|
Loading…
Reference in New Issue
Block a user