feat(friend): add ViewerFriend + ViewerFriendApply + ViewerPlayedTogether entities
Lays the persistence foundation for the /friend/* API surface. Three new model classes with composite PKs / unique constraints / FK cascades registered on SVSimDbContext; 4/4 persistence tests pass on SQLite in-memory. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
13
SVSim.Database/Models/ViewerFriend.cs
Normal file
13
SVSim.Database/Models/ViewerFriend.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One row per direction of a friendship. Approving an apply creates two rows
|
||||
/// (A → B and B → A). <see cref="FriendViewerId"/> from a played-together row
|
||||
/// can be self-joined against this table to detect an existing friendship.
|
||||
/// </summary>
|
||||
public class ViewerFriend
|
||||
{
|
||||
public long OwnerViewerId { get; set; }
|
||||
public long FriendViewerId { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
17
SVSim.Database/Models/ViewerFriendApply.cs
Normal file
17
SVSim.Database/Models/ViewerFriendApply.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One pending friend application. <see cref="Id"/> is the wire <c>apply_id</c>
|
||||
/// (auto-generated). Unique on <c>(FromViewerId, ToViewerId)</c> — a viewer can only
|
||||
/// have one outstanding apply to any given target.
|
||||
/// </summary>
|
||||
public class ViewerFriendApply
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public long FromViewerId { get; set; }
|
||||
public long ToViewerId { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
/// <summary>Beginner-friend campaign tag. Defaults to 0 (no campaign). Surfaces as optional <c>mission_type</c> on the wire.</summary>
|
||||
public int MissionType { get; set; }
|
||||
}
|
||||
17
SVSim.Database/Models/ViewerPlayedTogether.cs
Normal file
17
SVSim.Database/Models/ViewerPlayedTogether.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
namespace SVSim.Database.Models;
|
||||
|
||||
/// <summary>
|
||||
/// One row per (owner, opponent) pair. Upserted on each new battle so the table
|
||||
/// holds at most one row per opponent. Per-viewer 50-row retention cap pruned
|
||||
/// by <c>IPlayedTogetherWriter.RecordAsync</c>.
|
||||
/// </summary>
|
||||
public class ViewerPlayedTogether
|
||||
{
|
||||
public long OwnerViewerId { get; set; }
|
||||
public long OpponentViewerId { get; set; }
|
||||
public DateTime PlayedAt { get; set; }
|
||||
public int PlayedMode { get; set; }
|
||||
public int BattleType { get; set; }
|
||||
public int DeckFormat { get; set; }
|
||||
public int TwoPickType { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user