From 35b3bba596172bfda91b7364e1053282e00f6a08 Mon Sep 17 00:00:00 2001 From: Arthur Bassi Date: Mon, 29 Jun 2026 17:22:31 -0300 Subject: [PATCH] feat(work-orders): add EF config and Phase 0 migration --- .../Auth/ApplicationDbContext.cs | 21 + ...163145_Phase0_DomainFoundation.Designer.cs | 2987 +++++++++++++++++ .../20260624163145_Phase0_DomainFoundation.cs | 733 ++++ .../ApplicationDbContextModelSnapshot.cs | 245 +- 4 files changed, 3877 insertions(+), 109 deletions(-) create mode 100644 Data.SeaHavenIndustries/Migrations/20260624163145_Phase0_DomainFoundation.Designer.cs create mode 100644 Data.SeaHavenIndustries/Migrations/20260624163145_Phase0_DomainFoundation.cs diff --git a/Data.SeaHavenIndustries/Auth/ApplicationDbContext.cs b/Data.SeaHavenIndustries/Auth/ApplicationDbContext.cs index d66f708..40a6842 100644 --- a/Data.SeaHavenIndustries/Auth/ApplicationDbContext.cs +++ b/Data.SeaHavenIndustries/Auth/ApplicationDbContext.cs @@ -33,6 +33,24 @@ namespace Data.SeaHavenIndustries .HasIndex(u => new { u.DispatchId, u.Status }) .IsUnique() .HasFilter("[Status] = 'Pending'"); + + builder.Entity() + .HasIndex(l => new { l.WorkOrderId, l.FieldName }) + .IsUnique(); + + builder.Entity() + .Property(w => w.RowVersion) + .IsRowVersion(); + + builder.Entity() + .Property(d => d.RowVersion) + .IsRowVersion(); + + builder.Entity() + .HasOne(w => w.PrimaryDispatch) + .WithMany() + .HasForeignKey(w => w.PrimaryDispatchId) + .OnDelete(DeleteBehavior.Restrict); } public DbSet Categories { get; set; } public DbSet Locations { get; set; } @@ -47,6 +65,7 @@ namespace Data.SeaHavenIndustries public DbSet workOrderCategories { get; set; } public DbSet workOrderAttachments { get; set; } public DbSet WorkOrderAuditLogs { get; set; } + public DbSet WorkOrderFieldLocks { get; set; } public DbSet DropdownOptions { get; set; } public DbSet Vendors { get; set; } public DbSet VendorAccessTokens { get; set; } @@ -87,6 +106,8 @@ namespace Data.SeaHavenIndustries public DateTime? DeletedDate { get; set; } public bool? IsDeleted { get; set; } public string? UserImage { get; set; } + public string? Initials { get; set; } + public string? Color { get; set; } public int? Type { get; set; } // 1 for users 0 for admin public ICollection