using System; using FinlyticBot.Entities; using FinlyticCore.Database; using FinlyticCore.Entities.Settings; using Microsoft.EntityFrameworkCore; namespace FinlyticBot.Database; public class BotDbContext : DbContext, ISettingsDbContext { public BotDbContext(DbContextOptions options) : base(options) { } public DbSet DynamicSettings => Set(); public DbSet ExecutedPaperTrades => Set(); public DbSet BotAuditLogs => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.HasIndex(e => e.Key).IsUnique(); }); modelBuilder.Entity(entity => { entity.HasIndex(e => e.TradeId).IsUnique(); entity.HasIndex(e => e.Symbol); entity.HasIndex(e => e.Isin); entity.HasIndex(e => e.AlpacaOrderId); entity.HasIndex(e => e.Status); entity.HasIndex(e => e.PlacedAt); }); modelBuilder.Entity(entity => { entity.HasIndex(e => e.TradeId); entity.HasIndex(e => e.Symbol); entity.HasIndex(e => e.Action); entity.HasIndex(e => e.Timestamp); }); } }