Unify remaining DB model classes between SQLite and Postgres.
As part of this, the ban and unban table were renamed to server_* on SQLite to move them in line with Postgres. Data is preserved.
This commit is contained in:
@@ -98,13 +98,13 @@ namespace Content.Server.Database
|
||||
return bans;
|
||||
}
|
||||
|
||||
private static IQueryable<PostgresServerBan> MakeBanLookupQuery(
|
||||
private static IQueryable<ServerBan> MakeBanLookupQuery(
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId,
|
||||
DbGuardImpl db)
|
||||
{
|
||||
IQueryable<PostgresServerBan>? query = null;
|
||||
IQueryable<ServerBan>? query = null;
|
||||
|
||||
if (userId is { } uid)
|
||||
{
|
||||
@@ -137,7 +137,7 @@ namespace Content.Server.Database
|
||||
return query;
|
||||
}
|
||||
|
||||
private static ServerBanDef? ConvertBan(PostgresServerBan? ban)
|
||||
private static ServerBanDef? ConvertBan(ServerBan? ban)
|
||||
{
|
||||
if (ban == null)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ namespace Content.Server.Database
|
||||
unbanDef);
|
||||
}
|
||||
|
||||
private static ServerUnbanDef? ConvertUnban(PostgresServerUnban? unban)
|
||||
private static ServerUnbanDef? ConvertUnban(ServerUnban? unban)
|
||||
{
|
||||
if (unban == null)
|
||||
{
|
||||
@@ -193,7 +193,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
db.PgDbContext.Ban.Add(new PostgresServerBan
|
||||
db.PgDbContext.Ban.Add(new ServerBan
|
||||
{
|
||||
Address = serverBan.Address,
|
||||
HWId = serverBan.HWId?.ToArray(),
|
||||
@@ -211,7 +211,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
db.PgDbContext.Unban.Add(new PostgresServerUnban
|
||||
db.PgDbContext.Unban.Add(new ServerUnban
|
||||
{
|
||||
BanId = serverUnban.BanId,
|
||||
UnbanningAdmin = serverUnban.UnbanningAdmin?.UserId,
|
||||
@@ -240,7 +240,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
db.PgDbContext.ConnectionLog.Add(new PostgresConnectionLog
|
||||
db.PgDbContext.ConnectionLog.Add(new ConnectionLog
|
||||
{
|
||||
Address = address,
|
||||
Time = DateTime.UtcNow,
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Content.Server.Database
|
||||
}
|
||||
|
||||
private static bool BanMatches(
|
||||
SqliteServerBan ban,
|
||||
ServerBan ban,
|
||||
IPAddress? address,
|
||||
NetUserId? userId,
|
||||
ImmutableArray<byte>? hwId)
|
||||
@@ -124,7 +124,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
db.SqliteDbContext.Ban.Add(new SqliteServerBan
|
||||
db.SqliteDbContext.Ban.Add(new ServerBan
|
||||
{
|
||||
Address = serverBan.Address,
|
||||
Reason = serverBan.Reason,
|
||||
@@ -142,7 +142,7 @@ namespace Content.Server.Database
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
db.SqliteDbContext.Unban.Add(new SqliteServerUnban
|
||||
db.SqliteDbContext.Unban.Add(new ServerUnban
|
||||
{
|
||||
BanId = serverUnban.BanId,
|
||||
UnbanningAdmin = serverUnban.UnbanningAdmin?.UserId,
|
||||
@@ -163,7 +163,7 @@ namespace Content.Server.Database
|
||||
record.LastSeenHWId?.ToImmutableArray());
|
||||
}
|
||||
|
||||
private static ServerBanDef? ConvertBan(SqliteServerBan? ban)
|
||||
private static ServerBanDef? ConvertBan(ServerBan? ban)
|
||||
{
|
||||
if (ban == null)
|
||||
{
|
||||
@@ -196,7 +196,7 @@ namespace Content.Server.Database
|
||||
unban);
|
||||
}
|
||||
|
||||
private static ServerUnbanDef? ConvertUnban(SqliteServerUnban? unban)
|
||||
private static ServerUnbanDef? ConvertUnban(ServerUnban? unban)
|
||||
{
|
||||
if (unban == null)
|
||||
{
|
||||
@@ -220,9 +220,9 @@ namespace Content.Server.Database
|
||||
{
|
||||
await using var db = await GetDbImpl();
|
||||
|
||||
db.SqliteDbContext.ConnectionLog.Add(new SqliteConnectionLog
|
||||
db.SqliteDbContext.ConnectionLog.Add(new ConnectionLog
|
||||
{
|
||||
Address = address.ToString(),
|
||||
Address = address,
|
||||
Time = DateTime.UtcNow,
|
||||
UserId = userId.UserId,
|
||||
UserName = userName,
|
||||
@@ -298,7 +298,7 @@ namespace Content.Server.Database
|
||||
entity.Name = name;
|
||||
logEntities.Add(entity);
|
||||
}
|
||||
|
||||
|
||||
foreach (var player in log.Players)
|
||||
{
|
||||
player.LogId = log.Id;
|
||||
|
||||
Reference in New Issue
Block a user