mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
3.5 KiB
3.5 KiB
Database Drift Report — SQL vs EF
Fase: 0
Data: 2026-06-24
EF Snapshot: Data.SeaHavenIndustries/Migrations/ApplicationDbContextModelSnapshot.cs
Script legado: Api.SeaHavenIndustries/db.txt
1. Metodologia
- Colunas EF extraídas do
ApplicationDbContextModelSnapshot(entidadeWorkOrder). - Colunas SQL legado extraídas de
db.txtDDL[WorkOrders]. - Classificação: mapear, deprecar, satélite, OK.
2. Tabela workOrders — drift conhecido
| Coluna SQL (legado) | No EF? | Classificação | Ação Fase 0 |
|---|---|---|---|
| WorkOrderType | Não | mapear | Adicionar WorkOrderType int nullable → enum |
| AvettaTask | Não | inventariar | Adicionar coluna nullable; uso TBD com PO |
| AssignDate | Não | inventariar | Adicionar coluna nullable; possível alias AssignDate tracking |
| Nome tabela WorkOrders vs workOrders | EF usa workOrders |
OK | Manter EF naming; SQL Server case-insensitive |
3. Colunas EF (workOrders) — baseline
Presentes no snapshot e mapeadas:
InternalWONumber, ExternalWorkOrderId, WorkerOrderNumber, WorkerOrderTitle, Description, Customer, SiteCode, Building, Severity, DateReported, ScheduledStart, ScheduledDate, CompletedDate, Source, SourceEmailS3Key, Problem, Trade, SubTrade, VendorNTE, AssignTo, DueDate, Priority, Status, LocationId, PO, TT, Attachments, BeforPhoto*, AfterPhoto*, SignOff*, istemplate, audit fields (CreatedDate, IsDeleted, etc.)
4. Novas colunas Fase 0 (migration)
| Coluna | Tipo | Slice |
|---|---|---|
| LifecycleStatus | int nullable | Core |
| LegacyStatus | nvarchar (cópia Status) | Core |
| WorkOrderType | int nullable | Core |
| PrimaryDispatchId | int nullable FK | Core |
| RowVersion | rowversion | Core |
| TargetWeek | date nullable | Scheduling |
| ScheduledEnd | datetime2 nullable | Scheduling |
| ScheduleWeekOnly | bit nullable | Scheduling |
| OriginalWeek | date nullable | Tracking |
| OriginalDate | date nullable | Tracking |
| RescheduleCount | int default 0 | Analytics |
| CarriedOver | int default 0 | Analytics |
| DocStatus | int nullable | Completion |
| AvettaTask | nvarchar max nullable | Legado SQL |
| AssignDate | date nullable | Legado SQL |
5. Dispatch
| Item | EF | Ação Fase 0 |
|---|---|---|
| RowVersion | Ausente | Adicionar |
| Demais colunas | OK | Manter |
6. WorkOrderAuditLog
| Coluna | EF atual | Ação Fase 0 |
|---|---|---|
| EventType | Ausente | Adicionar |
| ActorType | Ausente | Adicionar |
| DispatchId | Ausente | Adicionar nullable |
| CorrelationId | Ausente | Adicionar nullable |
7. WorkOrderContacts
| Coluna | EF | Ação Fase 0 |
|---|---|---|
| Notes | Ausente | Adicionar nvarchar nullable (pocNotes) |
8. ApplicationUser (AspNetUsers)
| Coluna | Ação Fase 0 |
|---|---|
| Initials | nvarchar(8) nullable |
| Color | nvarchar(16) nullable |
9. Tabelas revisadas — sem drift crítico adicional
Comments— OKLocations— OK (SiteCode via WO.SiteCode)DispatchWorkOrders— OK
10. Recomendações
- Eliminar dual-path:
db.txtcatch-up não deve ser usado após migration EF Phase0; documentar em runbook. - WorkOrderType: mapear valores SQL existentes → enum na migration data script (dry-run).
- AvettaTask / AssignDate: manter nullable; PO valida uso antes de exposição board.
Gate: Diff assinado por Backend antes de merge migration.