25 lines
1.2 KiB
C#
25 lines
1.2 KiB
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
public class OcrResultConfiguration : IEntityTypeConfiguration<OcrResult>
|
|
{
|
|
public void Configure(EntityTypeBuilder<OcrResult> builder)
|
|
{
|
|
builder.ToTable("ocr_results");
|
|
builder.HasKey(o => o.Id);
|
|
builder.Property(o => o.Id).HasColumnName("id").HasDefaultValueSql("gen_random_uuid()");
|
|
builder.Property(o => o.BatchId).HasColumnName("batch_id").IsRequired();
|
|
builder.Property(o => o.Provider).HasColumnName("provider").HasMaxLength(20).IsRequired();
|
|
builder.Property(o => o.FieldConfidencesJson).HasColumnName("field_confidences_json").HasColumnType("jsonb").IsRequired();
|
|
builder.Property(o => o.RawText).HasColumnName("raw_text");
|
|
builder.Property(o => o.DurationMs).HasColumnName("duration_ms").IsRequired();
|
|
builder.Property(o => o.ProcessedAt).HasColumnName("processed_at").HasDefaultValueSql("NOW()");
|
|
|
|
builder.HasIndex(o => o.BatchId).IsUnique();
|
|
builder.HasOne(o => o.Batch)
|
|
.WithOne()
|
|
.HasForeignKey<OcrResult>(o => o.BatchId)
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
}
|
|
}
|