using CvMatcher.Data.Entities; using Microsoft.EntityFrameworkCore; namespace CvMatcher.Data; public sealed class CvMatcherDbContext : DbContext { public const string SchemaName = "cvMatcher"; public const string MigrationTableName = "_Migrations"; public CvMatcherDbContext(DbContextOptions options) : base(options) { } public DbSet CvMatchResults => Set(); public DbSet CvMatcherChatCache => Set(); protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasDefaultSchema(SchemaName); modelBuilder.Entity(entity => { entity.ToTable("Results"); entity.HasKey(x => x.Id); entity.Property(x => x.Id).HasMaxLength(64); entity.Property(x => x.CvDocumentId).HasMaxLength(64).IsRequired(); entity.Property(x => x.JobDocumentId).HasMaxLength(64).IsRequired(); entity.Property(x => x.ResultJson).IsRequired(); entity.Property(x => x.CreatedAt).HasDefaultValueSql("SYSUTCDATETIME()"); entity.HasIndex(x => new { x.CvDocumentId, x.JobDocumentId }).IsUnique(); }); modelBuilder.Entity(entity => { entity.ToTable("ChatCache"); entity.HasKey(x => x.CacheKey); entity.Property(x => x.CacheKey).HasMaxLength(64); entity.Property(x => x.Model).HasMaxLength(120).IsRequired(); entity.Property(x => x.Temperature).HasColumnType("decimal(4,2)"); entity.Property(x => x.ResponseText).IsRequired(); entity.Property(x => x.CreatedAt).HasDefaultValueSql("SYSUTCDATETIME()"); }); } }