using Microsoft.EntityFrameworkCore; using Svrnty.Sample.Data.Entities; namespace Svrnty.Sample.Data; /// /// Database context for AI agent system with conversation history and business data /// public class AgentDbContext : DbContext { public AgentDbContext(DbContextOptions options) : base(options) { } public DbSet Conversations => Set(); public DbSet Revenues => Set(); public DbSet Customers => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); // Configure Conversation entity modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.HasIndex(e => e.CreatedAt).HasDatabaseName("idx_conversations_created"); entity.HasIndex(e => e.UpdatedAt).HasDatabaseName("idx_conversations_updated"); entity.Property(e => e.MessagesJson) .HasColumnType("jsonb") .IsRequired() .HasDefaultValue("[]"); }); // Configure Revenue entity modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.HasIndex(e => new { e.Month, e.Year }) .HasDatabaseName("idx_revenue_month") .IsUnique(); entity.Property(e => e.Amount) .HasPrecision(18, 2); }); // Configure Customer entity modelBuilder.Entity(entity => { entity.HasKey(e => e.Id); entity.HasIndex(e => e.State).HasDatabaseName("idx_customers_state"); entity.HasIndex(e => e.Tier).HasDatabaseName("idx_customers_tier"); entity.HasIndex(e => new { e.State, e.Tier }) .HasDatabaseName("idx_customers_state_tier"); }); } }