feat(work-orders): add EF config and Phase 0 migration

This commit is contained in:
Arthur Bassi 2026-06-30 13:20:41 -03:00
parent 568961642f
commit e244c32bc9
4 changed files with 3896 additions and 109 deletions

View file

@ -33,6 +33,24 @@ namespace Data.SeaHavenIndustries
.HasIndex(u => new { u.DispatchId, u.Status })
.IsUnique()
.HasFilter("[Status] = 'Pending'");
builder.Entity<WorkOrderFieldLock>()
.HasIndex(l => new { l.WorkOrderId, l.FieldName })
.IsUnique();
builder.Entity<WorkOrder>()
.Property(w => w.RowVersion)
.IsRowVersion();
builder.Entity<Dispatch>()
.Property(d => d.RowVersion)
.IsRowVersion();
builder.Entity<WorkOrder>()
.HasOne(w => w.PrimaryDispatch)
.WithMany()
.HasForeignKey(w => w.PrimaryDispatchId)
.OnDelete(DeleteBehavior.Restrict);
}
public DbSet<Category> Categories { get; set; }
public DbSet<Locations> Locations { get; set; }
@ -47,6 +65,7 @@ namespace Data.SeaHavenIndustries
public DbSet<WorkOrderCategories> workOrderCategories { get; set; }
public DbSet<WorkOrderAttachments> workOrderAttachments { get; set; }
public DbSet<WorkOrderAuditLog> WorkOrderAuditLogs { get; set; }
public DbSet<WorkOrderFieldLock> WorkOrderFieldLocks { get; set; }
public DbSet<DropdownOption> DropdownOptions { get; set; }
public DbSet<Vendor> Vendors { get; set; }
public DbSet<VendorAccessToken> VendorAccessTokens { get; set; }
@ -88,6 +107,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<Template>? Templates { get; set; }
public ICollection<WorkOrder>? WorkOrders { get; set; }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,744 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
/// <inheritdoc />
public partial class Phase0_DomainFoundation : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Dispatches_workOrders_WorkOrderId",
table: "Dispatches");
migrationBuilder.DropForeignKey(
name: "FK_Locations_Accounts_AccountId",
table: "Locations");
migrationBuilder.DropIndex(
name: "IX_Locations_AccountId",
table: "Locations");
migrationBuilder.DropColumn(
name: "CreatedDate",
table: "Regions");
migrationBuilder.DropColumn(
name: "DeleterUserId",
table: "Regions");
migrationBuilder.DropColumn(
name: "DeletionTime",
table: "Regions");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "Regions");
migrationBuilder.DropColumn(
name: "LastModificationTime",
table: "Regions");
migrationBuilder.DropColumn(
name: "LastModifierUserId",
table: "Regions");
migrationBuilder.DropColumn(
name: "createdby",
table: "Regions");
migrationBuilder.DropColumn(
name: "AccountId",
table: "Locations");
migrationBuilder.DropColumn(
name: "CreatedDate",
table: "JobTitles");
migrationBuilder.DropColumn(
name: "DeleterUserId",
table: "JobTitles");
migrationBuilder.DropColumn(
name: "DeletionTime",
table: "JobTitles");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "JobTitles");
migrationBuilder.DropColumn(
name: "LastModificationTime",
table: "JobTitles");
migrationBuilder.DropColumn(
name: "LastModifierUserId",
table: "JobTitles");
migrationBuilder.DropColumn(
name: "createdby",
table: "JobTitles");
migrationBuilder.DropColumn(
name: "CreatedDate",
table: "EmployeeEmails");
migrationBuilder.DropColumn(
name: "DeleterUserId",
table: "EmployeeEmails");
migrationBuilder.DropColumn(
name: "DeletionTime",
table: "EmployeeEmails");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "EmployeeEmails");
migrationBuilder.DropColumn(
name: "LastModificationTime",
table: "EmployeeEmails");
migrationBuilder.DropColumn(
name: "LastModifierUserId",
table: "EmployeeEmails");
migrationBuilder.DropColumn(
name: "createdby",
table: "EmployeeEmails");
migrationBuilder.DropColumn(
name: "CreatedDate",
table: "Departments");
migrationBuilder.DropColumn(
name: "DeleterUserId",
table: "Departments");
migrationBuilder.DropColumn(
name: "DeletionTime",
table: "Departments");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "Departments");
migrationBuilder.DropColumn(
name: "LastModificationTime",
table: "Departments");
migrationBuilder.DropColumn(
name: "LastModifierUserId",
table: "Departments");
migrationBuilder.DropColumn(
name: "createdby",
table: "Departments");
migrationBuilder.RenameColumn(
name: "ZipCode",
table: "Locations",
newName: "Zip");
migrationBuilder.RenameColumn(
name: "Phone",
table: "Locations",
newName: "PhoneNumber");
migrationBuilder.RenameColumn(
name: "ContactEmail",
table: "Locations",
newName: "Email");
migrationBuilder.RenameColumn(
name: "Contact",
table: "Locations",
newName: "Address2");
migrationBuilder.RenameColumn(
name: "Address",
table: "Locations",
newName: "Address1");
migrationBuilder.AddColumn<DateOnly>(
name: "AssignDate",
table: "workOrders",
type: "date",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "AvettaTask",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "CarriedOver",
table: "workOrders",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "DocStatus",
table: "workOrders",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LegacyStatus",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "LifecycleStatus",
table: "workOrders",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "OperationalFlags",
table: "workOrders",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<DateOnly>(
name: "OriginalDate",
table: "workOrders",
type: "date",
nullable: true);
migrationBuilder.AddColumn<DateOnly>(
name: "OriginalWeek",
table: "workOrders",
type: "date",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "PrimaryDispatchId",
table: "workOrders",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "RescheduleCount",
table: "workOrders",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "workOrders",
type: "rowversion",
rowVersion: true,
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "ScheduleWeekOnly",
table: "workOrders",
type: "bit",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "ScheduledEnd",
table: "workOrders",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<DateOnly>(
name: "TargetWeek",
table: "workOrders",
type: "date",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "WorkOrderType",
table: "workOrders",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Service",
table: "workOrders",
type: "nvarchar(128)",
maxLength: 128,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Notes",
table: "WorkOrderContacts",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ActorType",
table: "WorkOrderAuditLogs",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "CorrelationId",
table: "WorkOrderAuditLogs",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "DispatchId",
table: "WorkOrderAuditLogs",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "EventType",
table: "WorkOrderAuditLogs",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<byte[]>(
name: "RowVersion",
table: "Dispatches",
type: "rowversion",
rowVersion: true,
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Color",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Initials",
table: "AspNetUsers",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.CreateTable(
name: "WorkOrderFieldLocks",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkOrderId = table.Column<int>(type: "int", nullable: false),
FieldName = table.Column<string>(type: "nvarchar(450)", nullable: false),
LockedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
LockedByUserId = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkOrderFieldLocks", x => x.Id);
table.ForeignKey(
name: "FK_WorkOrderFieldLocks_workOrders_WorkOrderId",
column: x => x.WorkOrderId,
principalTable: "workOrders",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_workOrders_PrimaryDispatchId",
table: "workOrders",
column: "PrimaryDispatchId");
migrationBuilder.CreateIndex(
name: "IX_WorkOrderFieldLocks_WorkOrderId_FieldName",
table: "WorkOrderFieldLocks",
columns: new[] { "WorkOrderId", "FieldName" },
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_Dispatches_workOrders_WorkOrderId",
table: "Dispatches",
column: "WorkOrderId",
principalTable: "workOrders",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_workOrders_Dispatches_PrimaryDispatchId",
table: "workOrders",
column: "PrimaryDispatchId",
principalTable: "Dispatches",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.Sql("""
UPDATE workOrders SET LegacyStatus = Status WHERE LegacyStatus IS NULL AND Status IS NOT NULL;
""");
migrationBuilder.Sql("""
UPDATE workOrders SET LifecycleStatus = CASE
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('open', 'incomplete') THEN 1
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('pending', 'onhold', 'on hold') THEN 2
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('scheduled') THEN 3
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('en route', 'enroute') THEN 4
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('on site', 'onsite') THEN 5
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('inprogress', 'in progress') THEN 6
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('completed', 'complete', 'done', 'closed') THEN 7
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('rescheduled') THEN 8
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('cancelled', 'canceled') THEN 9
WHEN LOWER(LTRIM(RTRIM(Status))) IN ('pending quote', 'pendingquote', 'pendingapproval', 'pending approval') THEN 10
ELSE 1
END
WHERE LifecycleStatus IS NULL AND Status IS NOT NULL;
""");
migrationBuilder.Sql("""
UPDATE wo SET wo.PrimaryDispatchId = latest.DispatchId
FROM workOrders wo
INNER JOIN (
SELECT WorkOrderId, MAX(Id) AS DispatchId
FROM Dispatches
WHERE WorkOrderId IS NOT NULL
GROUP BY WorkOrderId
) latest ON wo.Id = latest.WorkOrderId
WHERE wo.PrimaryDispatchId IS NULL;
""");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Dispatches_workOrders_WorkOrderId",
table: "Dispatches");
migrationBuilder.DropForeignKey(
name: "FK_workOrders_Dispatches_PrimaryDispatchId",
table: "workOrders");
migrationBuilder.DropTable(
name: "WorkOrderFieldLocks");
migrationBuilder.DropIndex(
name: "IX_workOrders_PrimaryDispatchId",
table: "workOrders");
migrationBuilder.DropColumn(
name: "AssignDate",
table: "workOrders");
migrationBuilder.DropColumn(
name: "AvettaTask",
table: "workOrders");
migrationBuilder.DropColumn(
name: "CarriedOver",
table: "workOrders");
migrationBuilder.DropColumn(
name: "DocStatus",
table: "workOrders");
migrationBuilder.DropColumn(
name: "LegacyStatus",
table: "workOrders");
migrationBuilder.DropColumn(
name: "LifecycleStatus",
table: "workOrders");
migrationBuilder.DropColumn(
name: "OperationalFlags",
table: "workOrders");
migrationBuilder.DropColumn(
name: "OriginalDate",
table: "workOrders");
migrationBuilder.DropColumn(
name: "OriginalWeek",
table: "workOrders");
migrationBuilder.DropColumn(
name: "PrimaryDispatchId",
table: "workOrders");
migrationBuilder.DropColumn(
name: "RescheduleCount",
table: "workOrders");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "workOrders");
migrationBuilder.DropColumn(
name: "ScheduleWeekOnly",
table: "workOrders");
migrationBuilder.DropColumn(
name: "ScheduledEnd",
table: "workOrders");
migrationBuilder.DropColumn(
name: "TargetWeek",
table: "workOrders");
migrationBuilder.DropColumn(
name: "WorkOrderType",
table: "workOrders");
migrationBuilder.DropColumn(
name: "Service",
table: "workOrders");
migrationBuilder.DropColumn(
name: "Notes",
table: "WorkOrderContacts");
migrationBuilder.DropColumn(
name: "ActorType",
table: "WorkOrderAuditLogs");
migrationBuilder.DropColumn(
name: "CorrelationId",
table: "WorkOrderAuditLogs");
migrationBuilder.DropColumn(
name: "DispatchId",
table: "WorkOrderAuditLogs");
migrationBuilder.DropColumn(
name: "EventType",
table: "WorkOrderAuditLogs");
migrationBuilder.DropColumn(
name: "RowVersion",
table: "Dispatches");
migrationBuilder.DropColumn(
name: "Color",
table: "AspNetUsers");
migrationBuilder.DropColumn(
name: "Initials",
table: "AspNetUsers");
migrationBuilder.RenameColumn(
name: "Zip",
table: "Locations",
newName: "ZipCode");
migrationBuilder.RenameColumn(
name: "PhoneNumber",
table: "Locations",
newName: "Phone");
migrationBuilder.RenameColumn(
name: "Email",
table: "Locations",
newName: "ContactEmail");
migrationBuilder.RenameColumn(
name: "Address2",
table: "Locations",
newName: "Contact");
migrationBuilder.RenameColumn(
name: "Address1",
table: "Locations",
newName: "Address");
migrationBuilder.AddColumn<DateTime>(
name: "CreatedDate",
table: "Regions",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "DeleterUserId",
table: "Regions",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DeletionTime",
table: "Regions",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "Regions",
type: "bit",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "LastModificationTime",
table: "Regions",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "LastModifierUserId",
table: "Regions",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "createdby",
table: "Regions",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "AccountId",
table: "Locations",
type: "int",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "CreatedDate",
table: "JobTitles",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "DeleterUserId",
table: "JobTitles",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DeletionTime",
table: "JobTitles",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "JobTitles",
type: "bit",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "LastModificationTime",
table: "JobTitles",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "LastModifierUserId",
table: "JobTitles",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "createdby",
table: "JobTitles",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "CreatedDate",
table: "EmployeeEmails",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "DeleterUserId",
table: "EmployeeEmails",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DeletionTime",
table: "EmployeeEmails",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "EmployeeEmails",
type: "bit",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "LastModificationTime",
table: "EmployeeEmails",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "LastModifierUserId",
table: "EmployeeEmails",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "createdby",
table: "EmployeeEmails",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "CreatedDate",
table: "Departments",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "DeleterUserId",
table: "Departments",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DeletionTime",
table: "Departments",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "Departments",
type: "bit",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "LastModificationTime",
table: "Departments",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "LastModifierUserId",
table: "Departments",
type: "int",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "createdby",
table: "Departments",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Locations_AccountId",
table: "Locations",
column: "AccountId");
migrationBuilder.AddForeignKey(
name: "FK_Dispatches_workOrders_WorkOrderId",
table: "Dispatches",
column: "WorkOrderId",
principalTable: "workOrders",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Locations_Accounts_AccountId",
table: "Locations",
column: "AccountId",
principalTable: "Accounts",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}

View file

@ -186,6 +186,9 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("Color")
.HasColumnType("nvarchar(max)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
@ -209,6 +212,9 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Initials")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
@ -601,32 +607,11 @@ namespace Data.SeaHavenIndustries.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Departments");
@ -688,6 +673,11 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("ReplyToAddress")
.HasColumnType("nvarchar(max)");
b.Property<byte[]>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property<DateTime?>("ScheduledDate")
.HasColumnType("datetime2");
@ -1111,36 +1101,15 @@ namespace Data.SeaHavenIndustries.Migrations
.HasMaxLength(256)
.HasColumnType("nvarchar(256)");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<int?>("EmailTypeId")
.HasColumnType("int");
b.Property<int>("EmployeeId")
.HasColumnType("int");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<bool?>("IsPrimary")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("EmployeeId");
@ -1279,32 +1248,11 @@ namespace Data.SeaHavenIndustries.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("JobTitles");
@ -1318,21 +1266,15 @@ namespace Data.SeaHavenIndustries.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("AccountId")
.HasColumnType("int");
b.Property<string>("Address1")
.HasColumnType("nvarchar(max)");
b.Property<string>("Address")
b.Property<string>("Address2")
.HasColumnType("nvarchar(max)");
b.Property<string>("City")
.HasColumnType("nvarchar(max)");
b.Property<string>("Contact")
.HasColumnType("nvarchar(max)");
b.Property<string>("ContactEmail")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
@ -1342,6 +1284,9 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
@ -1360,7 +1305,7 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<string>("Phone")
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<string>("State")
@ -1372,7 +1317,7 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<string>("ZipCode")
b.Property<string>("Zip")
.HasColumnType("nvarchar(max)");
b.Property<string>("createdby")
@ -1380,8 +1325,6 @@ namespace Data.SeaHavenIndustries.Migrations
b.HasKey("Id");
b.HasIndex("AccountId");
b.ToTable("Locations");
});
@ -1573,32 +1516,11 @@ namespace Data.SeaHavenIndustries.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<DateTime?>("CreatedDate")
.HasColumnType("datetime2");
b.Property<string>("DeleterUserId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2");
b.Property<bool?>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2");
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("createdby")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Regions");
@ -1931,12 +1853,18 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("AfterPhotoIssue")
.HasColumnType("nvarchar(max)");
b.Property<DateOnly?>("AssignDate")
.HasColumnType("date");
b.Property<string>("AssignTo")
.HasColumnType("nvarchar(450)");
b.Property<string>("Attachments")
.HasColumnType("nvarchar(max)");
b.Property<string>("AvettaTask")
.HasColumnType("nvarchar(max)");
b.Property<string>("BeforPhotoAttachment")
.HasColumnType("nvarchar(max)");
@ -1946,6 +1874,9 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("Building")
.HasColumnType("nvarchar(max)");
b.Property<int>("CarriedOver")
.HasColumnType("int");
b.Property<DateTime?>("CompletedDate")
.HasColumnType("datetime2");
@ -1967,6 +1898,9 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<int?>("DocStatus")
.HasColumnType("int");
b.Property<DateTime?>("DueDate")
.HasColumnType("datetime2");
@ -1985,27 +1919,63 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("LegacyStatus")
.HasColumnType("nvarchar(max)");
b.Property<int?>("LifecycleStatus")
.HasColumnType("int");
b.Property<int?>("LocationId")
.HasColumnType("int");
b.Property<int>("OperationalFlags")
.HasColumnType("int");
b.Property<DateOnly?>("OriginalDate")
.HasColumnType("date");
b.Property<DateOnly?>("OriginalWeek")
.HasColumnType("date");
b.Property<string>("PO")
.HasColumnType("nvarchar(max)");
b.Property<int?>("PrimaryDispatchId")
.HasColumnType("int");
b.Property<string>("Priority")
.HasColumnType("nvarchar(max)");
b.Property<string>("Problem")
.HasColumnType("nvarchar(max)");
b.Property<int>("RescheduleCount")
.HasColumnType("int");
b.Property<byte[]>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property<bool?>("ScheduleWeekOnly")
.HasColumnType("bit");
b.Property<DateTime?>("ScheduledDate")
.HasColumnType("datetime2");
b.Property<DateTime?>("ScheduledEnd")
.HasColumnType("datetime2");
b.Property<DateTime?>("ScheduledStart")
.HasColumnType("datetime2");
b.Property<string>("Severity")
.HasColumnType("nvarchar(max)");
b.Property<string>("Service")
.HasMaxLength(128)
.HasColumnType("nvarchar(128)");
b.Property<string>("SignOffAttachment")
.HasColumnType("nvarchar(max)");
@ -2033,12 +2003,18 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("TT")
.HasColumnType("nvarchar(max)");
b.Property<DateOnly?>("TargetWeek")
.HasColumnType("date");
b.Property<string>("Trade")
.HasColumnType("nvarchar(max)");
b.Property<decimal?>("VendorNTE")
.HasColumnType("decimal(18,2)");
b.Property<int?>("WorkOrderType")
.HasColumnType("int");
b.Property<string>("WorkerOrderNumber")
.HasColumnType("nvarchar(max)");
@ -2057,6 +2033,8 @@ namespace Data.SeaHavenIndustries.Migrations
b.HasIndex("LocationId");
b.HasIndex("PrimaryDispatchId");
b.ToTable("workOrders");
});
@ -2113,9 +2091,21 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<string>("Action")
.HasColumnType("nvarchar(max)");
b.Property<string>("ActorType")
.HasColumnType("nvarchar(max)");
b.Property<string>("CorrelationId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<int?>("DispatchId")
.HasColumnType("int");
b.Property<string>("EventType")
.HasColumnType("nvarchar(max)");
b.Property<string>("FieldName")
.HasColumnType("nvarchar(max)");
@ -2213,6 +2203,9 @@ namespace Data.SeaHavenIndustries.Migrations
b.Property<int?>("LastModifierUserId")
.HasColumnType("int");
b.Property<string>("Notes")
.HasColumnType("nvarchar(max)");
b.Property<int?>("WorkorderId")
.HasColumnType("int");
@ -2228,6 +2221,35 @@ namespace Data.SeaHavenIndustries.Migrations
b.ToTable("WorkOrderContacts");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrderFieldLock", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("FieldName")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<DateTime>("LockedAt")
.HasColumnType("datetime2");
b.Property<string>("LockedByUserId")
.HasColumnType("nvarchar(max)");
b.Property<int>("WorkOrderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("WorkOrderId", "FieldName")
.IsUnique();
b.ToTable("WorkOrderFieldLocks");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
@ -2457,8 +2479,7 @@ namespace Data.SeaHavenIndustries.Migrations
b.HasOne("Data.SeaHavenIndustries.WorkOrder", "WorkOrder")
.WithMany("Dispatches")
.HasForeignKey("WorkOrderId")
.OnDelete(DeleteBehavior.Restrict);
.HasForeignKey("WorkOrderId");
b.Navigation("Vendor");
@ -2612,16 +2633,6 @@ namespace Data.SeaHavenIndustries.Migrations
b.Navigation("WorkOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.Locations", b =>
{
b.HasOne("Data.SeaHavenIndustries.Accounts", "Account")
.WithMany()
.HasForeignKey("AccountId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Account");
});
modelBuilder.Entity("Data.SeaHavenIndustries.PMSchedules", b =>
{
b.HasOne("Data.SeaHavenIndustries.Assets", "Asset")
@ -2731,9 +2742,16 @@ namespace Data.SeaHavenIndustries.Migrations
.HasForeignKey("LocationId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("Data.SeaHavenIndustries.Dispatch", "PrimaryDispatch")
.WithMany()
.HasForeignKey("PrimaryDispatchId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("AssignToUser");
b.Navigation("Locations");
b.Navigation("PrimaryDispatch");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrderAttachments", b =>
@ -2798,6 +2816,17 @@ namespace Data.SeaHavenIndustries.Migrations
b.Navigation("WorkOrder");
});
modelBuilder.Entity("Data.SeaHavenIndustries.WorkOrderFieldLock", b =>
{
b.HasOne("Data.SeaHavenIndustries.WorkOrder", "WorkOrder")
.WithMany("FieldLocks")
.HasForeignKey("WorkOrderId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("WorkOrder");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
@ -2943,6 +2972,8 @@ namespace Data.SeaHavenIndustries.Migrations
b.Navigation("Dispatches");
b.Navigation("FieldLocks");
b.Navigation("Quotes");
b.Navigation("WorkOrderCategories");