Fix admin notes and database time nonsense. (#25280)
God bloody christ. There's like three layers of shit here. So firstly, apparently we were still using Npgsql.EnableLegacyTimestampBehavior. This means that time values (which are stored UTC in the database) were converted to local time when read out. This meant they were passed around as kind Local to clients (instead of UTC in the case of SQLite). That's easy enough to fix just turn off the flag and fix the couple spots we're passing a local DateTime ez. Oh but it turns out there's a DIFFERENT problem with SQLite: See SQLite we definitely store the DateTimes as UTC, but when Microsoft.Data.Sqlite reads them it reads them as Kind Unspecified instead of Utc. Why are these so bad? Because the admin notes system passes DateTime instances from EF Core straight to the rest of the game code. And that means it's a PAIN IN THE ASS to run the necessary conversions to fix the DateTime instances. GOD DAMNIT now I have to make a whole new set of "Record" entities so we avoid leaking the EF Core model entities. WAAAAAAA. Fixes #19897
This commit is contained in:
committed by
GitHub
parent
2907e84b6f
commit
2e6eaa45c5
@@ -874,33 +874,8 @@ namespace Content.Server.Database
|
||||
public byte[] Data { get; set; } = default!;
|
||||
}
|
||||
|
||||
public interface IAdminRemarksCommon
|
||||
{
|
||||
public int Id { get; }
|
||||
|
||||
public int? RoundId { get; }
|
||||
public Round? Round { get; }
|
||||
|
||||
public Guid? PlayerUserId { get; }
|
||||
public Player? Player { get; }
|
||||
public TimeSpan PlaytimeAtNote { get; }
|
||||
|
||||
public string Message { get; }
|
||||
|
||||
public Player? CreatedBy { get; }
|
||||
|
||||
public DateTime CreatedAt { get; }
|
||||
|
||||
public Player? LastEditedBy { get; }
|
||||
|
||||
public DateTime? LastEditedAt { get; }
|
||||
public DateTime? ExpirationTime { get; }
|
||||
|
||||
public bool Deleted { get; }
|
||||
}
|
||||
|
||||
[Index(nameof(PlayerUserId))]
|
||||
public class AdminNote : IAdminRemarksCommon
|
||||
public class AdminNote
|
||||
{
|
||||
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }
|
||||
|
||||
@@ -934,7 +909,7 @@ namespace Content.Server.Database
|
||||
}
|
||||
|
||||
[Index(nameof(PlayerUserId))]
|
||||
public class AdminWatchlist : IAdminRemarksCommon
|
||||
public class AdminWatchlist
|
||||
{
|
||||
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }
|
||||
|
||||
@@ -965,7 +940,7 @@ namespace Content.Server.Database
|
||||
}
|
||||
|
||||
[Index(nameof(PlayerUserId))]
|
||||
public class AdminMessage : IAdminRemarksCommon
|
||||
public class AdminMessage
|
||||
{
|
||||
[Required, Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; }
|
||||
|
||||
|
||||
@@ -10,11 +10,6 @@ namespace Content.Server.Database
|
||||
{
|
||||
public sealed class PostgresServerDbContext : ServerDbContext
|
||||
{
|
||||
static PostgresServerDbContext()
|
||||
{
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
}
|
||||
|
||||
public PostgresServerDbContext(DbContextOptions<PostgresServerDbContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user