diff --git a/OshimaBot/Data/BotDbContext.cs b/OshimaBot/Data/BotDbContext.cs
new file mode 100644
index 0000000..0c99663
--- /dev/null
+++ b/OshimaBot/Data/BotDbContext.cs
@@ -0,0 +1,185 @@
+using Microsoft.EntityFrameworkCore;
+using OshimaBot.Data.Entities;
+
+namespace OshimaBot.Data;
+
+///
+/// P0~P2 所需表。P3(clubs / rooms / betting_* 等)按计划不进入首批 Migration。
+/// 不规则字段用 TEXT 存 JSON,由应用层序列化,可查询字段一律列式。
+/// 外键关系在 S6 仓储层落地时补齐,当前先建表、主键与索引。
+///
+public sealed class BotDbContext(DbContextOptions options) : DbContext(options)
+{
+ public DbSet Users => Set();
+ public DbSet UserIdentities => Set();
+ public DbSet UserRoles => Set();
+ public DbSet ApiKeys => Set();
+ public DbSet BindCodes => Set();
+ public DbSet AuditLogs => Set();
+
+ public DbSet PlayerStates => Set();
+ public DbSet Characters => Set();
+ public DbSet CharacterSkills => Set();
+ public DbSet CharacterEquipment => Set();
+ public DbSet ItemInstances => Set();
+ public DbSet Squads => Set();
+ public DbSet SquadMembers => Set();
+ public DbSet TrainingSessions => Set();
+ public DbSet DailyQuests => Set();
+ public DbSet SignInRecords => Set();
+ public DbSet ActivityProgress => Set();
+ public DbSet ExplorationRuns => Set();
+ public DbSet ForgingJobs => Set();
+ public DbSet MailMessages => Set();
+ public DbSet RenameRequests => Set();
+ public DbSet UserSessions => Set();
+
+ public DbSet LedgerEntries => Set();
+ public DbSet Stores => Set();
+ public DbSet StoreGoods => Set();
+ public DbSet MarketListings => Set();
+ public DbSet Trades => Set();
+ public DbSet TradeItems => Set();
+
+ public DbSet ProcessedEvents => Set();
+ public DbSet GatewaySessions => Set();
+ public DbSet SimulationRuns => Set();
+ public DbSet SimulationStatistics => Set();
+ public DbSet AppConfigs => Set();
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
+
+ // ---- 身份与权限 ----
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => x.Handle).IsUnique();
+ entity.Property(x => x.Version).IsConcurrencyToken();
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.Provider, x.Subject }).IsUnique();
+ entity.HasIndex(x => x.UserId);
+ entity.HasIndex(x => x.UnionSubject);
+ });
+ modelBuilder.Entity().HasKey(x => new { x.UserId, x.Role });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => x.KeyHash).IsUnique();
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Code);
+ entity.HasIndex(x => x.UserId);
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.ActorUserId, x.CreatedAtUtc });
+ });
+
+ // ---- 玩家存档 ----
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.UserId);
+ entity.Property(x => x.Version).IsConcurrencyToken();
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.UserId, x.IsMain });
+ });
+ modelBuilder.Entity().HasKey(x => new { x.CharacterId, x.SkillId, x.Slot });
+ modelBuilder.Entity().HasKey(x => new { x.CharacterId, x.Slot });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.UserId, x.CatalogId });
+ entity.Property(x => x.Version).IsConcurrencyToken();
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => x.UserId);
+ });
+ modelBuilder.Entity().HasKey(x => new { x.SquadId, x.Slot });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.UserId, x.SettledAtUtc });
+ });
+ modelBuilder.Entity().HasKey(x => new { x.UserId, x.QuestKey, x.QuestDate });
+ modelBuilder.Entity().HasKey(x => new { x.UserId, x.SignInDate });
+ modelBuilder.Entity().HasKey(x => new { x.UserId, x.ActivityKey });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.UserId, x.SettledAtUtc });
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.UserId, x.SettledAtUtc });
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.ReceiverUserId, x.ReadAtUtc });
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.Status, x.CreatedAtUtc });
+ });
+ modelBuilder.Entity().HasKey(x => x.UserId);
+
+ // ---- 经济与交易 ----
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.UserId, x.CreatedAtUtc });
+ entity.HasIndex(x => new { x.RefType, x.RefId });
+ });
+ modelBuilder.Entity().HasKey(x => x.Key);
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => x.StoreKey);
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.Status, x.CreatedAtUtc });
+ entity.HasIndex(x => x.SellerUserId);
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => x.SellerUserId);
+ });
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => x.TradeId);
+ });
+
+ // ---- 系统 / 运行 ----
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => new { x.EventId, x.MsgSeq });
+ entity.HasIndex(x => x.ReceivedAtUtc);
+ });
+ modelBuilder.Entity().HasKey(x => x.BotAppId);
+ modelBuilder.Entity(entity =>
+ {
+ entity.HasKey(x => x.Id);
+ entity.HasIndex(x => new { x.UserId, x.StartedAtUtc });
+ });
+ modelBuilder.Entity().HasKey(x => new { x.Scope, x.CatalogId });
+ modelBuilder.Entity().HasKey(x => x.Key);
+ }
+}
diff --git a/OshimaBot/Data/DatabaseInitializer.cs b/OshimaBot/Data/DatabaseInitializer.cs
new file mode 100644
index 0000000..dde2da5
--- /dev/null
+++ b/OshimaBot/Data/DatabaseInitializer.cs
@@ -0,0 +1,31 @@
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Options;
+using OshimaBot.Models;
+
+namespace OshimaBot.Data;
+
+///
+/// 放在 IHostedService 中而非 Program 启动代码里:EF CLI 设计时只构建 Host、不启动 HostedService,
+/// 从而避免生成 Migration 时反过来尝试执行 Migration。
+///
+public sealed class DatabaseInitializer(
+ IServiceScopeFactory scopeFactory,
+ IOptions options,
+ ILogger logger) : BackgroundService
+{
+ protected override async Task ExecuteAsync(CancellationToken stoppingToken)
+ {
+ if (!options.Value.ApplyMigrationsOnStartup)
+ {
+ logger.LogInformation("已跳过数据库自动迁移(Database:ApplyMigrationsOnStartup=false)。");
+ return;
+ }
+
+ using IServiceScope scope = scopeFactory.CreateScope();
+ BotDbContext db = scope.ServiceProvider.GetRequiredService();
+ await db.Database.MigrateAsync(stoppingToken);
+ await db.Database.ExecuteSqlRawAsync("PRAGMA journal_mode=WAL;", stoppingToken);
+ await db.Database.ExecuteSqlRawAsync("PRAGMA foreign_keys=ON;", stoppingToken);
+ logger.LogInformation("数据库迁移完成,已启用 WAL 与外键约束。");
+ }
+}
diff --git a/OshimaBot/Data/Economy.cs b/OshimaBot/Data/Economy.cs
new file mode 100644
index 0000000..2aa942f
--- /dev/null
+++ b/OshimaBot/Data/Economy.cs
@@ -0,0 +1,68 @@
+namespace OshimaBot.Data.Entities;
+
+/// 所有货币变动必须与「加物品/扣物品」在同一事务写入,用于对账与防丢。
+public sealed class LedgerEntry
+{
+ public long Id { get; set; }
+ public long UserId { get; set; }
+ public string Currency { get; set; } = "credits";
+ public long Delta { get; set; }
+ public long BalanceAfter { get; set; }
+ public string Reason { get; set; } = "";
+ public string RefType { get; set; } = "";
+ public string RefId { get; set; } = "";
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+}
+
+public sealed class Store
+{
+ public string Key { get; set; } = "";
+ public string Name { get; set; } = "";
+ public string Kind { get; set; } = "system";
+ public DateTime? RefreshAtUtc { get; set; }
+ public string ConfigJson { get; set; } = "{}";
+}
+
+public sealed class StoreGood
+{
+ public long Id { get; set; }
+ public string StoreKey { get; set; } = "";
+ public string ItemCatalogId { get; set; } = "";
+ public string PriceCurrency { get; set; } = "credits";
+ public long Price { get; set; }
+ public int Stock { get; set; } = -1;
+ public int Quota { get; set; } = -1;
+ public DateTime? RefreshAtUtc { get; set; }
+}
+
+public sealed class MarketListing
+{
+ public long Id { get; set; }
+ public long SellerUserId { get; set; }
+ public long ItemInstanceId { get; set; }
+ public long Price { get; set; }
+ public long Fee { get; set; }
+ public int Status { get; set; }
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+ public DateTime? ClosedAtUtc { get; set; }
+}
+
+public sealed class Trade
+{
+ public long Id { get; set; }
+ public long? BuyerUserId { get; set; }
+ public long SellerUserId { get; set; }
+ public int Status { get; set; }
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+ public DateTime? ClosedAtUtc { get; set; }
+}
+
+public sealed class TradeItem
+{
+ public long Id { get; set; }
+ public long TradeId { get; set; }
+ public long FromUserId { get; set; }
+ public long ItemInstanceId { get; set; }
+ public int Quantity { get; set; } = 1;
+ public long Price { get; set; }
+}
diff --git a/OshimaBot/Data/Identity.cs b/OshimaBot/Data/Identity.cs
new file mode 100644
index 0000000..cd3827e
--- /dev/null
+++ b/OshimaBot/Data/Identity.cs
@@ -0,0 +1,64 @@
+namespace OshimaBot.Data.Entities;
+
+/// 内部用户主键。业务代码只使用 Id,外部 OpenID 单独存 UserIdentity。
+public sealed class User
+{
+ public long Id { get; set; }
+ public string Handle { get; set; } = "";
+ public string Nickname { get; set; } = "";
+ public int Status { get; set; }
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+ public DateTime LastSeenAtUtc { get; set; } = DateTime.UtcNow;
+ public int Version { get; set; }
+}
+
+/// 外部身份(QQ user_openid / member_openid 等),支持多身份、换绑与 union_openid 合并。
+public sealed class UserIdentity
+{
+ public long Id { get; set; }
+ public long UserId { get; set; }
+ public string Provider { get; set; } = "qq";
+ public string Subject { get; set; } = "";
+ public string? UnionSubject { get; set; }
+ public string Scene { get; set; } = "c2c";
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+}
+
+public sealed class UserRole
+{
+ public long UserId { get; set; }
+ public int Role { get; set; }
+}
+
+public sealed class ApiKey
+{
+ public long Id { get; set; }
+ public long? UserId { get; set; }
+ public string Name { get; set; } = "";
+ public string KeyHash { get; set; } = "";
+ public string ScopesJson { get; set; } = "[]";
+ public DateTime? ExpiresAtUtc { get; set; }
+ public DateTime? RevokedAtUtc { get; set; }
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+}
+
+/// 一次性绑定码,用于第三方/管理端绑定 QQ OpenID,替代旧版直接回显接入码。
+public sealed class BindCode
+{
+ public string Code { get; set; } = "";
+ public long UserId { get; set; }
+ public string Purpose { get; set; } = "";
+ public DateTime ExpiresAtUtc { get; set; }
+ public DateTime? UsedAtUtc { get; set; }
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+}
+
+public sealed class AuditLog
+{
+ public long Id { get; set; }
+ public long? ActorUserId { get; set; }
+ public string Action { get; set; } = "";
+ public string Target { get; set; } = "";
+ public string PayloadJson { get; set; } = "{}";
+ public DateTime CreatedAtUtc { get; set; } = DateTime.UtcNow;
+}
diff --git a/OshimaBot/Data/Migrations/20261109125643_Initial.Designer.cs b/OshimaBot/Data/Migrations/20261109125643_Initial.Designer.cs
new file mode 100644
index 0000000..8e9cb16
--- /dev/null
+++ b/OshimaBot/Data/Migrations/20261109125643_Initial.Designer.cs
@@ -0,0 +1,1009 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using OshimaBot.Data;
+
+#nullable disable
+
+namespace OshimaBot.Data.Migrations
+{
+ [DbContext(typeof(BotDbContext))]
+ [Migration("20261109125643_Initial")]
+ partial class Initial
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "10.0.11");
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.ActivityProgress", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActivityKey")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimedJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ProgressJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "ActivityKey");
+
+ b.ToTable("ActivityProgress");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.ApiKey", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ExpiresAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("KeyHash")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RevokedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ScopesJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("KeyHash")
+ .IsUnique();
+
+ b.ToTable("ApiKeys");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.AppConfig", b =>
+ {
+ b.Property("Key")
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ValueJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Key");
+
+ b.ToTable("AppConfigs");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.AuditLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Action")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ActorUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("PayloadJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Target")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ActorUserId", "CreatedAtUtc");
+
+ b.ToTable("AuditLogs");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.BindCode", b =>
+ {
+ b.Property("Code")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ExpiresAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Purpose")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UsedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Code");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("BindCodes");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.Character", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AttrsJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("BreakLevel")
+ .HasColumnType("INTEGER");
+
+ b.Property("CatalogId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("CatalogVersion")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Exp")
+ .HasColumnType("INTEGER");
+
+ b.Property("IsMain")
+ .HasColumnType("INTEGER");
+
+ b.Property("Level")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "IsMain");
+
+ b.ToTable("Characters");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.CharacterEquipment", b =>
+ {
+ b.Property("CharacterId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Slot")
+ .HasColumnType("TEXT");
+
+ b.Property("ItemInstanceId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("CharacterId", "Slot");
+
+ b.ToTable("CharacterEquipment");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.CharacterSkill", b =>
+ {
+ b.Property("CharacterId")
+ .HasColumnType("INTEGER");
+
+ b.Property("SkillId")
+ .HasColumnType("TEXT");
+
+ b.Property("Slot")
+ .HasColumnType("INTEGER");
+
+ b.Property("Level")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("CharacterId", "SkillId", "Slot");
+
+ b.ToTable("CharacterSkills");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.DailyQuest", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("QuestKey")
+ .HasColumnType("TEXT");
+
+ b.Property("QuestDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ClaimedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ProgressJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserId", "QuestKey", "QuestDate");
+
+ b.ToTable("DailyQuests");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.ExplorationRun", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("EndsAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("RegionKey")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("SettledAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("StartedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("StateJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "SettledAtUtc");
+
+ b.ToTable("ExplorationRuns");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.ForgingJob", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("EndsAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("RecipeKey")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("SettledAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("StartedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("StateJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "SettledAtUtc");
+
+ b.ToTable("ForgingJobs");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.GatewaySession", b =>
+ {
+ b.Property("BotAppId")
+ .HasColumnType("TEXT");
+
+ b.Property("LastSeq")
+ .HasColumnType("INTEGER");
+
+ b.Property("SessionId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.HasKey("BotAppId");
+
+ b.ToTable("GatewaySessions");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.ItemInstance", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AcquiredAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Bound")
+ .HasColumnType("INTEGER");
+
+ b.Property("CatalogId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Locked")
+ .HasColumnType("INTEGER");
+
+ b.Property("PayloadJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Quality")
+ .HasColumnType("INTEGER");
+
+ b.Property("Quantity")
+ .HasColumnType("INTEGER");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "CatalogId");
+
+ b.ToTable("ItemInstances");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.LedgerEntry", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BalanceAfter")
+ .HasColumnType("INTEGER");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Currency")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Delta")
+ .HasColumnType("INTEGER");
+
+ b.Property("Reason")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RefId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RefType")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RefType", "RefId");
+
+ b.HasIndex("UserId", "CreatedAtUtc");
+
+ b.ToTable("LedgerEntries");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.MailMessage", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Content")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ReadAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ReceiverUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("SenderUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Subject")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ReceiverUserId", "ReadAtUtc");
+
+ b.ToTable("MailMessages");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.MarketListing", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ClosedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Fee")
+ .HasColumnType("INTEGER");
+
+ b.Property("ItemInstanceId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Price")
+ .HasColumnType("INTEGER");
+
+ b.Property("SellerUserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Status")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("SellerUserId");
+
+ b.HasIndex("Status", "CreatedAtUtc");
+
+ b.ToTable("MarketListings");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.PlayerState", b =>
+ {
+ b.Property("UserId")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CooperativePoints")
+ .HasColumnType("INTEGER");
+
+ b.Property("Credits")
+ .HasColumnType("INTEGER");
+
+ b.Property("Diamonds")
+ .HasColumnType("INTEGER");
+
+ b.Property("DinnerClaimedOn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Exp")
+ .HasColumnType("INTEGER");
+
+ b.Property("ExploreTimes")
+ .HasColumnType("INTEGER");
+
+ b.Property("ForgePoints")
+ .HasColumnType("INTEGER");
+
+ b.Property("HorseRacingPoints")
+ .HasColumnType("INTEGER");
+
+ b.Property("Level")
+ .HasColumnType("INTEGER");
+
+ b.Property("LogonOn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("LunchClaimedOn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("SignInStreak")
+ .HasColumnType("INTEGER");
+
+ b.Property("SignedOn")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Version")
+ .IsConcurrencyToken()
+ .HasColumnType("INTEGER");
+
+ b.HasKey("UserId");
+
+ b.ToTable("PlayerStates");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.ProcessedEvent", b =>
+ {
+ b.Property("EventId")
+ .HasColumnType("TEXT");
+
+ b.Property("MsgSeq")
+ .HasColumnType("INTEGER");
+
+ b.Property("ProcessedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("ReceivedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.HasKey("EventId", "MsgSeq");
+
+ b.HasIndex("ReceivedAtUtc");
+
+ b.ToTable("ProcessedEvents");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.RenameRequest", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("RequestedName")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ReviewedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("Status")
+ .HasColumnType("INTEGER");
+
+ b.Property("TargetId")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("TargetType")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Status", "CreatedAtUtc");
+
+ b.ToTable("RenameRequests");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.SignInRecord", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.Property("SignInDate")
+ .HasColumnType("TEXT");
+
+ b.Property("CreatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("RewardJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("UserId", "SignInDate");
+
+ b.ToTable("SignInRecords");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.SimulationRun", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("FinishedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("OptionsJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ResultJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("RoundsJson")
+ .HasColumnType("TEXT");
+
+ b.Property("Seed")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("StartedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.Property("UserId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId", "StartedAtUtc");
+
+ b.ToTable("SimulationRuns");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.SimulationStatistic", b =>
+ {
+ b.Property("Scope")
+ .HasColumnType("TEXT");
+
+ b.Property("CatalogId")
+ .HasColumnType("TEXT");
+
+ b.Property("StatsJson")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("UpdatedAtUtc")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Scope", "CatalogId");
+
+ b.ToTable("SimulationStatistics");
+ });
+
+ modelBuilder.Entity("OshimaBot.Data.Entities.Squad", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("IsActive")
+ .HasColumnType("INTEGER");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property