shoc-backend/Data.SeaHavenIndustries/Migrations/20260416212330_AddExternalSyncFields.cs
Adam Moussa 6f8f67735a Add DynamoDB sync bridge for workorder-ingest pipeline
- Add ExternalWorkOrderId, Customer, SiteCode, Building, Severity,
  DateReported, ScheduledStart, SourceEmailS3Key to WorkOrder model
- Add Commenter, RecordType, ExternalCommentId to Comments model
- Add AWSSDK.DynamoDBv2 package
- Create SyncController with endpoints:
  - POST /api/Sync/WorkOrders — scans DynamoDB WorkOrders table, upserts into SQL
  - POST /api/Sync/Comments — scans DynamoDB WorkOrderComments, creates Comments
  - POST /api/Sync/All — runs both
- Auto-creates Locations from site_code/building/address during sync
- Maps DynamoDB status values to SHOC status strings
- Maps severity to SHOC priority format (Sev N)
- Deduplicates on ExternalWorkOrderId / ExternalCommentId
2026-04-16 17:29:52 -04:00

129 lines
3.8 KiB
C#

using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Data.SeaHavenIndustries.Migrations
{
/// <inheritdoc />
public partial class AddExternalSyncFields : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "Building",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Customer",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DateReported",
table: "workOrders",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ExternalWorkOrderId",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "ScheduledStart",
table: "workOrders",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Severity",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SiteCode",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "SourceEmailS3Key",
table: "workOrders",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Commenter",
table: "Comments",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ExternalCommentId",
table: "Comments",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "RecordType",
table: "Comments",
type: "nvarchar(max)",
nullable: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Building",
table: "workOrders");
migrationBuilder.DropColumn(
name: "Customer",
table: "workOrders");
migrationBuilder.DropColumn(
name: "DateReported",
table: "workOrders");
migrationBuilder.DropColumn(
name: "ExternalWorkOrderId",
table: "workOrders");
migrationBuilder.DropColumn(
name: "ScheduledStart",
table: "workOrders");
migrationBuilder.DropColumn(
name: "Severity",
table: "workOrders");
migrationBuilder.DropColumn(
name: "SiteCode",
table: "workOrders");
migrationBuilder.DropColumn(
name: "SourceEmailS3Key",
table: "workOrders");
migrationBuilder.DropColumn(
name: "Commenter",
table: "Comments");
migrationBuilder.DropColumn(
name: "ExternalCommentId",
table: "Comments");
migrationBuilder.DropColumn(
name: "RecordType",
table: "Comments");
}
}
}