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:
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
@@ -14,10 +13,6 @@ namespace Content.Server.Database
|
||||
{
|
||||
public sealed class SqliteServerDbContext : ServerDbContext
|
||||
{
|
||||
public DbSet<SqliteServerBan> Ban { get; set; } = default!;
|
||||
public DbSet<SqliteServerUnban> Unban { get; set; } = default!;
|
||||
public DbSet<SqliteConnectionLog> ConnectionLog { get; set; } = default!;
|
||||
|
||||
public SqliteServerDbContext()
|
||||
{
|
||||
}
|
||||
@@ -47,9 +42,6 @@ namespace Content.Server.Database
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<Player>()
|
||||
.HasIndex(p => p.LastSeenUserName);
|
||||
|
||||
var ipConverter = new ValueConverter<IPAddress, string>(
|
||||
v => v.ToString(),
|
||||
v => IPAddress.Parse(v));
|
||||
@@ -64,7 +56,7 @@ namespace Content.Server.Database
|
||||
);
|
||||
|
||||
modelBuilder
|
||||
.Entity<SqliteServerBan>()
|
||||
.Entity<ServerBan>()
|
||||
.Property(e => e.Address)
|
||||
.HasColumnType("TEXT")
|
||||
.HasConversion(ipMaskConverter);
|
||||
@@ -117,45 +109,4 @@ namespace Content.Server.Database
|
||||
return JsonDocument.Parse(str);
|
||||
}
|
||||
}
|
||||
|
||||
[Table("ban")]
|
||||
public class SqliteServerBan
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public Guid? UserId { get; set; }
|
||||
public (IPAddress address, int mask)? Address { get; set; }
|
||||
public byte[]? HWId { get; set; }
|
||||
|
||||
public DateTime BanTime { get; set; }
|
||||
public DateTime? ExpirationTime { get; set; }
|
||||
public string Reason { get; set; } = null!;
|
||||
public Guid? BanningAdmin { get; set; }
|
||||
|
||||
public SqliteServerUnban? Unban { get; set; }
|
||||
}
|
||||
|
||||
[Table("unban")]
|
||||
public class SqliteServerUnban
|
||||
{
|
||||
[Column("unban_id")] public int Id { get; set; }
|
||||
|
||||
public int BanId { get; set; }
|
||||
public SqliteServerBan Ban { get; set; } = null!;
|
||||
|
||||
public Guid? UnbanningAdmin { get; set; }
|
||||
public DateTime UnbanTime { get; set; }
|
||||
}
|
||||
|
||||
[Table("connection_log")]
|
||||
public class SqliteConnectionLog
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public Guid UserId { get; set; }
|
||||
public string UserName { get; set; } = null!;
|
||||
public DateTime Time { get; set; }
|
||||
public string Address { get; set; } = null!;
|
||||
public byte[]? HWId { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user