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:
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user