feat: add Drawing entity with revision tracking

Introduce a Drawing table that tracks unique drawing numbers with their
current PDF content hash and revision counter. ExportRecord gains a
DrawingId FK. Includes a data migration to seed Drawings from existing
export records.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-20 08:54:01 -05:00
parent 13c61a82a4
commit c5bd7fb4c8
8 changed files with 861 additions and 0 deletions

View File

@@ -9,6 +9,7 @@ namespace FabWorks.Core.Data
public DbSet<BomItem> BomItems { get; set; }
public DbSet<CutTemplate> CutTemplates { get; set; }
public DbSet<FormProgram> FormPrograms { get; set; }
public DbSet<Drawing> Drawings { get; set; }
public FabWorksDbContext(DbContextOptions<FabWorksDbContext> options) : base(options) { }
@@ -32,6 +33,11 @@ namespace FabWorks.Core.Data
.WithOne(b => b.ExportRecord)
.HasForeignKey(b => b.ExportRecordId)
.OnDelete(DeleteBehavior.Cascade);
entity.HasOne(e => e.Drawing)
.WithMany(d => d.ExportRecords)
.HasForeignKey(e => e.DrawingId)
.OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<BomItem>(entity =>
@@ -74,6 +80,15 @@ namespace FabWorks.Core.Data
entity.Property(e => e.LowerToolNames).HasMaxLength(500);
entity.Property(e => e.SetupNotes).HasMaxLength(2000);
});
modelBuilder.Entity<Drawing>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.DrawingNumber).HasMaxLength(100);
entity.Property(e => e.Title).HasMaxLength(200);
entity.Property(e => e.PdfContentHash).HasMaxLength(64);
entity.HasIndex(e => e.DrawingNumber).IsUnique();
});
}
}
}