initial commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
public class DraftObservationConfiguration : IEntityTypeConfiguration<DraftObservation>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<DraftObservation> builder)
|
||||
{
|
||||
builder.ToTable("draft_observations");
|
||||
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.ObservationCode).HasColumnName("observation_code").HasMaxLength(50).IsRequired();
|
||||
builder.Property(o => o.Value).HasColumnName("value").HasColumnType("decimal(10,3)").IsRequired();
|
||||
builder.Property(o => o.Unit).HasColumnName("unit").HasMaxLength(20).IsRequired();
|
||||
builder.Property(o => o.RecordedAt).HasColumnName("recorded_at").IsRequired();
|
||||
builder.Property(o => o.Note).HasColumnName("note").HasMaxLength(500);
|
||||
builder.Property(o => o.CreatedAt).HasColumnName("created_at").HasDefaultValueSql("NOW()");
|
||||
|
||||
builder.HasOne(o => o.Batch).WithMany(b => b.DraftObservations).HasForeignKey(o => o.BatchId).OnDelete(DeleteBehavior.Cascade);
|
||||
builder.HasIndex(o => new { o.BatchId, o.ObservationCode });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user