# sub-database-agent-1 — Design-review Mig 69 `AddContractSigningPlans` (S161 W1, READ-ONLY advisory) > Ghi TỪNG MỤC trong lúc làm (chống #53). Không sửa file production. Không commit. > Nguồn đo: file migration + Designer + ModelSnapshot + 7 EF Configuration + sqlcmd LocalDB Dev/Design. ## VERDICT TỔNG (điền cuối, xem §END) --- ## 0. Vật liệu đã đọc (evidence anchors) | Vật | Đường dẫn | Ghi chú | |---|---|---| | Migration | `src/Backend/SolutionErp.Infrastructure/Persistence/Migrations/20260729122015_AddContractSigningPlans.cs` | 373 dòng | | Designer | `...20260729122015_AddContractSigningPlans.Designer.cs` | 264.515 B | | Snapshot | `...Migrations/ApplicationDbContextModelSnapshot.cs` | 264.399 B, git diff +550/-0 | | Config ×7 | `src/Backend/SolutionErp.Infrastructure/Persistence/Configurations/ContractSigningPlan*.cs` | 7 file | | Spec W1 | `.claude/workflows/runs/2026-07-29-S160-khkk-dryrun-plan/spec-wave-w1-schema-designer-29-07-2026.md:16-20` | §②-2/4/6 | | Spec gốc maxLength | `.claude/workflows/runs/2026-07-28-S157-ke-hoach-ky-ket-hd/spec-ke-hoach-ky-ket-hd-28-07-2026.md:134-137` | danh sách 11 cột chuỗi | Đếm operation trong migration (grep + uniq): - `CreateTable` ×7 · `CreateIndex` ×20 · `DropTable` ×7 (Down) - `AddColumn` / `AlterColumn` / `DropColumn` / `RenameColumn` / `Sql(` = **0** (không match nào) --- ## 3. Đối chứng sqlcmd LocalDB (DB1/DB10 — schema THẬT, không trí nhớ) `sqlcmd -S "(localdb)\MSSQLLocalDB" -d SolutionErp_Dev -E` : ``` TABLECOUNT|96 CSPTABLE|ContractSigningPlanApprovals CSPTABLE|ContractSigningPlanAttachments CSPTABLE|ContractSigningPlanChangelogs CSPTABLE|ContractSigningPlanDossierItems CSPTABLE|ContractSigningPlanLevelOpinions CSPTABLE|ContractSigningPlanLines CSPTABLE|ContractSigningPlans MIGTOP|20260729122015_AddContractSigningPlans MIGCOUNT|69 ``` `-d SolutionErp_Design` : ``` DESIGN_TABLECOUNT|96 · DESIGN_CSP|7 · DESIGN_MIGTOP|20260729122015_AddContractSigningPlans · DESIGN_IXCOUNT|27 ``` → **2 DB parity TUYỆT ĐỐI** (96/96 bảng · 7/7 CSP · cùng mig-top · 27 index = 20 IX + 7 PK). → **KHÔNG có committed-but-unapplied-local drift** (khác bẫy S53). → Acceptance §③-B "sys.tables 89 → 96" = **ĐẠT** (đo được 96; delta +7 khớp 7 CreateTable). ### Index thật trong DB (27 dòng, khớp 1:1 file mig) Nhóm filtered (soi gotcha #57): ``` ContractSigningPlanLines | IX_..._ContractSigningPlanId_SupplierId | unique=1 | ([IsDeleted]=(0)) | ContractSigningPlanId,SupplierId ContractSigningPlans | IX_ContractSigningPlans_MaKeHoach | unique=1 | ([MaKeHoach] IS NOT NULL) | MaKeHoach ``` Các IX còn lại filter = `-` (không filter), unique=0 trừ `IX_ContractSigningPlanLevelOpinions_ContractSigningPlanId_ApprovalWorkflowLevelId` (unique=1, **không** filter — bàn ở §2e/§4). ### FK thật (8 FK, cột `delete_referential_action_desc`) ``` Approvals → ContractSigningPlans CASCADE Attachments → ContractSigningPlans CASCADE Changelogs → ContractSigningPlans CASCADE DossierItems → ContractSigningPlans CASCADE LevelOpinions→ ContractSigningPlans CASCADE Lines → ContractSigningPlans CASCADE LevelOpinions→ ApprovalWorkflowLevels NO_ACTION (= Restrict) ContractSigningPlans → ApprovalWorkflows NO_ACTION (= Restrict) ``` → 6 con Cascade 1-hop + 2 Restrict, **đúng y spec §②-2/4**. Zero FK vật lý sang PE/Project/Supplier/User/Contract (loose-Guid, convention Mig 49) — xác nhận bằng chính danh sách 8 FK trên (không có dòng nào trỏ `PurchaseEvaluations`/`Suppliers`/`Projects`). ---